aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/default/textures/default_rail.png
blob: 777e10c00404de93965cdbe42f02015572efb796 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 03 00 00 00 28 2d 0f .PNG........IHDR.............(-.
0020 53 00 00 00 db 50 4c 54 45 00 00 00 55 57 53 5c 41 18 64 47 1b 64 48 1a 69 4a 1b 69 4a 1c 6a 4b S....PLTE...UWS\A.dG.dH.iJ.iJ.jK
0040 1c 6a 4c 1c 6b 4c 1c 6d 4d 1c 6d 4e 1d 6e 4e 1d 6f 4f 1d 6f 4f 1e 70 4f 1d 70 50 1e 71 50 1e 71 .jL.kL.mM.mN.nN.oO.oO.pO.pP.qP.q
0060 51 1e 72 50 1e 72 51 1e 73 52 1f 74 53 1e 74 53 1f 75 53 1f 76 54 1f 77 55 1f 78 55 1f 79 56 1f Q.rP.rQ.sR.tS.tS.uS.vT.wU.xU.yV.
0080 79 56 20 7a 57 20 7b 57 20 7f 5b 21 80 5b 22 80 5c 22 81 5b 22 86 63 2b 89 65 2c 8b 67 2d 90 6a yV.zW.{W..[!.[".\".[".c+.e,.g-.j
00a0 2f 91 6b 2f 93 6d 30 95 6d 30 95 6e 30 96 6f 30 96 6f 31 98 71 32 99 72 32 9a 72 32 9a 73 32 9b /.k/.m0.m0.n0.o0.o1.q2.r2.r2.s2.
00c0 73 33 9c 74 32 9c 74 33 9d 74 33 9f 75 33 9f 75 34 a1 76 34 a2 77 35 a3 79 35 a4 78 35 a4 79 36 s3.t2.t3.t3.u3.u4.v4.w5.y5.x5.y6
00e0 a5 7a 36 a7 7b 37 a8 7d 37 a9 7c 37 ab 7e 38 af 81 39 b0 83 39 b3 84 3a b4 86 3a b6 87 3b b7 87 .z6.{7.}7.|7.~8..9..9..:..:..;..
0100 3c ba bd b6 b8 64 fa 52 00 00 00 01 74 52 4e 53 00 40 e6 d8 66 00 00 00 88 49 44 41 54 18 57 8d <....d.R....tRNS.@..f....IDAT.W.
0120 8c 45 12 c2 00 00 c4 76 71 b7 52 a0 b8 53 dc 8a bb ef ff 5f c4 85 5b 2f e4 98 99 04 80 88 1f 14 .E.....vq.R..S....._..[/........
0140 00 7c 44 db 39 ec 2e ce a4 4d 6d 00 04 c5 b2 af 50 cc 26 32 4d 2a 0a b8 13 97 d8 8b d3 e1 e3 b9 .|D.9....Mm.....P.&2M*..........
0160 b8 6e 3b d4 0b 40 5d cc 05 cc 7c 29 1d 8e 51 8d bf 1e 27 71 bc ee cf df a3 65 8f 5a 01 48 8a 71 .n;..@]...|)..Q...'q.....e.Z.H.q
0180 33 14 69 59 46 8a f2 ff f5 98 89 f7 e3 aa 7b 3b db 03 ca 06 60 89 46 35 5d ab c4 12 5e ca e3 4e 3.iYF.........{;....`.F5]...^..N
01a0 be 07 62 14 41 e3 14 5e bd 00 00 00 00 49 45 4e 44 ae 42 60 82 ..b.A..^.....IEND.B`.
href='#n131'>131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 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 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
/*
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.
*/

#pragma once

#include "irr_v3d.h"
#include "map.h"
#include "hud.h"
#include "gamedef.h"
#include "serialization.h" // For SER_FMT_VER_INVALID
#include "content/mods.h"
#include "inventorymanager.h"
#include "content/subgames.h"
#include "tileanimation.h" // struct TileAnimationParams
#include "network/peerhandler.h"
#include "network/address.h"
#include "util/numeric.h"
#include "util/thread.h"
#include "util/basic_macros.h"
#include "serverenvironment.h"
#include "clientiface.h"
#include "chatmessage.h"
#include <string>
#include <list>
#include <map>
#include <vector>

class ChatEvent;
struct ChatEventChat;
struct ChatInterface;
class IWritableItemDefManager;
class NodeDefManager;
class IWritableCraftDefManager;
class BanManager;
class EventManager;
class Inventory;
class ModChannelMgr;
class RemotePlayer;
class PlayerSAO;
struct PlayerHPChangeReason;
class IRollbackManager;
struct RollbackAction;
class EmergeManager;
class ServerScripting;
class ServerEnvironment;
struct SimpleSoundSpec;
struct CloudParams;
class ServerThread;
class ServerModManager;

enum ClientDeletionReason {
	CDR_LEAVE,
	CDR_TIMEOUT,
	CDR_DENY
};

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
{
	enum Type {
		SSP_LOCAL,
		SSP_POSITIONAL,
		SSP_OBJECT
	} type = SSP_LOCAL;
	float gain = 1.0f;
	float fade = 0.0f;
	float pitch = 1.0f;
	bool loop = false;
	float max_hear_distance = 32 * BS;
	v3f pos;
	u16 object = 0;
	std::string to_player = "";

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

struct ServerPlayingSound
{
	ServerSoundParams params;
	SimpleSoundSpec spec;
	std::unordered_set<session_t> 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,
		Address bind_addr,
		bool dedicated,
		ChatInterface *iface = nullptr
	);
	~Server();
	DISABLE_CLASS_COPY(Server);

	void init();
	void start();
	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(session_t peer_id);

	/*
	 * Command Handlers
	 */

	void handleCommand(NetworkPacket* pkt);

	void handleCommand_Null(NetworkPacket* pkt) {};
	void handleCommand_Deprecated(NetworkPacket* pkt);
	void handleCommand_Init(NetworkPacket* pkt);
	void handleCommand_Init2(NetworkPacket* pkt);
	void handleCommand_ModChannelJoin(NetworkPacket *pkt);
	void handleCommand_ModChannelLeave(NetworkPacket *pkt);
	void handleCommand_ModChannelMsg(NetworkPacket *pkt);
	void handleCommand_RequestMedia(NetworkPacket* pkt);
	void handleCommand_ClientReady(NetworkPacket* pkt);
	void handleCommand_GotBlocks(NetworkPacket* pkt);
	void handleCommand_PlayerPos(NetworkPacket* pkt);
	void handleCommand_DeletedBlocks(NetworkPacket* pkt);
	void handleCommand_InventoryAction(NetworkPacket* pkt);
	void handleCommand_ChatMessage(NetworkPacket* pkt);
	void handleCommand_Damage(NetworkPacket* pkt);
	void handleCommand_Password(NetworkPacket* pkt);
	void handleCommand_PlayerItem(NetworkPacket* pkt);
	void handleCommand_Respawn(NetworkPacket* pkt);
	void handleCommand_Interact(NetworkPacket* pkt);
	void handleCommand_RemovedSounds(NetworkPacket* pkt);
	void handleCommand_NodeMetaFields(NetworkPacket* pkt);
	void handleCommand_InventoryFields(NetworkPacket* pkt);
	void handleCommand_FirstSrp(NetworkPacket* pkt);
	void handleCommand_SrpBytesA(NetworkPacket* pkt);
	void handleCommand_SrpBytesM(NetworkPacket* pkt);

	void ProcessData(NetworkPacket *pkt);

	void Send(NetworkPacket *pkt);
	void Send(session_t peer_id, NetworkPacket *pkt);

	// Helper for handleCommand_PlayerPos and handleCommand_Interact
	void process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
		NetworkPacket *pkt);

	// Both setter and getter need no envlock,
	// can be called freely from threads
	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, bool playerSend = true);

	// Connection must be locked when called
	std::wstring getStatusString();
	inline double getUptime() const { return m_uptime.m_value; }

	// read shutdown state
	inline bool isShutdownRequested() const { return m_shutdown_state.is_requested; }

	// request server to shutdown
	void requestShutdown(const std::string &msg, bool reconnect, float delay = 0.0f);

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

	// 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 reportFormspecPrependModified(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 std::string &playername,
		v3f pos, v3f velocity, v3f acceleration,
		float expirationtime, float size,
		bool collisiondetection, bool collision_removal, bool object_collision,
		bool vertical, const std::string &texture,
		const struct TileAnimationParams &animation, u8 glow);

	u32 addParticleSpawner(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 collision_removal, bool object_collision,
		ServerActiveObject *attached,
		bool vertical, const std::string &texture,
		const std::string &playername, const struct TileAnimationParams &animation,
		u8 glow);

	void deleteParticleSpawner(const std::string &playername, u32 id);

	// Creates or resets inventory
	Inventory *createDetachedInventory(const std::string &name,
			const std::string &player = "");
	bool removeDetachedInventory(const std::string &name);

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

	// 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 const NodeDefManager* getNodeDefManager();
	virtual ICraftDefManager* getCraftDefManager();
	virtual u16 allocateUnknownNodeId(const std::string &name);
	IRollbackManager *getRollbackManager() { return m_rollback; }
	virtual EmergeManager *getEmergeManager() { return m_emerge; }

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

	virtual const std::vector<ModSpec> &getMods() const;
	virtual const ModSpec* getModSpec(const std::string &modname) const;
	void getModNames(std::vector<std::string> &modlist);
	std::string getBuiltinLuaPath();
	virtual std::string getWorldPath() const { return m_path_world; }
	virtual std::string getModStoragePath() const;

	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; }
	v3f findSpawnPos();

	u32 hudAdd(RemotePlayer *player, HudElement *element);
	bool hudRemove(RemotePlayer *player, u32 id);
	bool hudChange(RemotePlayer *player, u32 id, HudElementStat stat, void *value);
	bool hudSetFlags(RemotePlayer *player, u32 flags, u32 mask);
	bool hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount);
	void hudSetHotbarImage(RemotePlayer *player, std::string name);
	void hudSetHotbarSelectedImage(RemotePlayer *player, std::string name);

	Address getPeerAddress(session_t peer_id);

	void setLocalPlayerAnimations(RemotePlayer *player, v2s32 animation_frames[4],
			f32 frame_speed);
	void setPlayerEyeOffset(RemotePlayer *player, const v3f &first, const v3f &third);