aboutsummaryrefslogtreecommitdiff
path: root/textures/mobs_horsepeg.png
blob: 4442c0d9b975efcaa244ee6446de9d8cf8f71a7d (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 20 08 03 00 00 00 95 43 8e .PNG........IHDR...@..........C.
0020 b6 00 00 00 60 50 4c 54 45 43 3e 3d 4d 48 47 51 4c 4b 55 50 4f 53 55 52 59 55 54 60 5b 59 4c 5f ....`PLTEC>=MHGQLKUPOSURYUT`[YL_
0040 75 64 5f 5e 67 63 61 6b 66 65 6e 6a 68 77 72 71 db d5 d4 d6 d8 d5 df da d8 db dd da e3 dd dc de ud_^gcakfenjhwrq................
0060 e0 dd e0 e2 df e6 e1 e0 e9 e3 e2 e3 e5 e2 e5 e8 e4 ec e6 e5 ef ea e8 ea ec e9 f4 ee ed f3 f5 f2 ................................
0080 fa f4 f3 ff fb f9 fc fe fa 88 ef ae 22 00 00 03 89 49 44 41 54 48 c7 85 95 8b 76 a3 30 0c 44 29 ............"....IDATH....v.0.D)
00a0 29 2c e1 61 5b b2 84 6c f2 fa ff bf dc 11 e9 36 d9 66 73 56 39 2d 81 e0 8b 3c 1a 89 46 ef 11 43 ),.a[..l.......6.fsV9-...<..F..C
00c0 60 5e a2 0e e3 78 d4 ad 14 93 b2 29 a9 99 28 65 66 36 36 55 8e 24 91 42 4c a4 df d1 7c 1d 17 44 `^...x.....)..(ef66U.$.BL...|..D
00e0 04 60 9a c6 11 a7 45 c8 4c b9 58 64 21 52 21 ce 0e 08 89 38 85 98 cb 2b 20 04 00 80 1e 8f e3 48 .`....E.L.Xd!R!....8...+.......H
0100 6b 31 3c b3 6e 45 4b a9 9b 6e f5 64 ce 54 d3 ac 4a cc 54 e5 27 40 02 61 03 91 62 5c 99 12 9e cd k1<.nEK..n.d.T..J.T.'@.a..b\....
0120 5c eb e5 7c 39 9d 0c 9f f3 69 3b 6d 15 79 63 2d ad 89 a9 bc 02 62 88 cb 4e 48 91 28 45 ec b8 6c \..|9....i;m.yc-.....b..NH.(E..l
0140 d7 eb ed 7c c3 df e9 76 be 5c 6e 37 51 c0 39 23 2b ec ee 15 b0 50 72 15 98 74 35 06 c9 6c 3b df ...|...v.\n7Q.9#+....Pr..t5..l;.
0160 b0 cc e3 ba 1f f1 d4 62 5b e1 75 7d d2 f0 5b 03 92 44 4b dc f5 4a b2 86 c8 6a f5 74 bb 54 cf fe .......b[.u}..[..DK..J...j.t.T..
0180 72 bd 5e f0 11 dd 56 82 88 8b 24 93 57 00 14 8c 71 49 86 2f 9a b1 9e d8 8e 43 7f 1c 87 e1 38 dc r.^...V...$.W...qI./.....C....8.
01a0 63 c6 4d cb 02 b1 21 f8 2b 60 09 d8 42 5c 42 84 00 50 49 90 08 77 07 8f ae 3d f8 97 b6 9d e7 a1 c.M...!.+`..B\B..PI..w...=......
01c0 eb 11 87 ee 73 98 e7 97 32 62 f7 d8 43 4e 2c 31 bb 0c 09 6e f1 f5 ed 61 fe 8e c3 87 83 0e 87 a6 ....s...2b..CN,1...n...a........
01e0 f3 b3 1f 5b 80 c0 0b 1e 8d 1c 20 34 f4 96 4c 76 e8 3a 3c 7c be 20 76 00 4e 3f 0f 9f c8 a9 bb 03 ...[.......4..Lv.:<|..v.N?......
0200 ef 00 54 8c a4 c4 94 f9 2e 05 34 48 5f d4 f9 47 74 fd a1 df f7 33 3c ae 35 b0 1c ad 9a bd c0 0e ..T.......4H_..Gt....3<.5.......
0220 20 0a 89 59 9f e3 71 73 df 7e 20 89 ae fd 93 c1 0e c8 9c 3d 7d d6 ea 37 b3 bb 21 dc 61 af 80 b6 ...Y..qs.~.........=}..7..!.a...
0240 6d da 8f b6 69 9a f6 19 20 14 00 80 45 e1 f4 d5 b2 08 c3 f4 ab c0 32 d5 b6 8a b6 99 a7 be 9f 86 m...i.......E.........2.........
0260 a1 1f c6 be ef b0 83 fe 13 a5 41 cb a0 c2 fd 71 6e 68 49 10 0e d6 03 24 65 2b 4c d1 13 a2 82 d6 ..........A....qnhI....$e+L.....
0280 61 f4 91 a7 15 96 90 a2 1b 20 f9 3f 74 fe e2 97 bc 81 83 36 70 7e 60 48 4f 11 cb 00 90 ac a8 03 a..........?t......6p~`HO.......
02a0 41 57 b4 0e f2 f0 59 01 83 f9 82 dd 24 f0 98 9b 4c 51 2f d4 6c d1 26 38 11 0f 88 ee 00 2b 15 ad AW....Y.....$...LQ/.l.&8.....+..
02c0 82 05 64 a5 68 4a bb 32 02 7f 84 04 7f 49 de ed 4a b6 92 78 5f 0a a6 8b 36 9e 1d ee 88 11 43 43 ..d.hJ.2.....I..J..x_...6.....CC
02e0 b0 5c c5 f0 9b f9 50 82 14 ea 19 64 f2 46 45 c3 8b 6b 85 21 61 e8 5a f2 7e 23 db 33 20 74 1f 8c .\....P....d.FE..k.!a.Z.~#.3.t..
0300 17 a1 e3 6a 9b 21 47 64 82 c0 28 d9 bc 71 f3 2e 91 40 2b f1 7c c8 9b 1f 38 17 eb e1 c4 af a8 d5 ...j.!Gd..(..q...@+.|...8.......
0320 67 8f fd 7d 91 c2 92 e0 6e 83 3b b3 57 5a 7d 62 54 88 ac b9 be 00 7c 78 da 4f 40 a4 f2 eb 57 35 g..}....n.;.WZ}bT.....|x.O@...W5
0340 ab a8 11 aa 55 30 3c b9 e2 4a f1 2d e8 ff c3 4b 7c bd 9e 4c 80 17 12 ca d0 93 2b ae 78 ba 6f 00 ....U0<..J.-...K|..L......+.x.o.
0360 4f 0d b0 37 5a 3c 6f 1b 6b 46 5d 8b 65 d2 2c 86 59 09 5e 7e 0b f0 f7 c3 e0 6e 03 c0 4d a2 96 a0 O..7Z<o.kF].e.,.Y.^~.....n..M...
0380 63 86 c6 c5 0a 1a d5 6a c5 e8 86 29 de 01 46 bc 20 86 71 da 01 ec 0e 5b 51 1a 31 31 f5 99 6f 88 c......j...)..F...q....[Q.11..o.
03a0 95 7d 74 be 07 8c 13 12 98 26 07 ac 10 bf fa 28 46 db ae 2b 56 e3 85 83 4a c5 04 03 be 05 4c e8 .}t......&.....(F..+V...J.....L.
03c0 1f 2c 9f 46 00 4a 46 61 e0 2c a4 52 b6 22 68 95 8a a3 8f f2 f8 1e 30 ce 13 02 49 cc 4f 57 4b 91 .,.F.JFa.,.R."h.......0...I.OWK.
03e0 b5 90 fe eb c5 f2 9a c1 0c 06 34 18 e7 c7 fc 54 74 a8 bf db 12 ff e3 dd f8 13 70 dc 11 50 72 ea ..........4....Tt.........p..Pr.
0400 9f 72 b0 bd a4 28 e6 ff 01 3e 2e 50 45 00 8e 0f 80 0f 2a b4 a2 cf 9e ef f8 0d 69 53 91 07 f8 f2 .r...(...>.PE.....*.......iS....
0420 22 4a 00 00 00 00 49 45 4e 44 ae 42 60 82 "J....IEND.B`.
22 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 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965
/*
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.
*/

/*
(c) 2010 Perttu Ahola <celeron55@gmail.com>
*/

#include "inventory.h"
#include "serialization.h"
#include "utility.h"
#include "debug.h"
#include <sstream>
#include "main.h"
#include "serverobject.h"
#include "content_mapnode.h"
#include "content_inventory.h"
#include "content_sao.h"
#include "player.h"

/*
	InventoryItem
*/

InventoryItem::InventoryItem(u16 count)
{
	m_count = count;
}

InventoryItem::~InventoryItem()
{
}

InventoryItem* InventoryItem::deSerialize(std::istream &is)
{
	DSTACK(__FUNCTION_NAME);

	//is.imbue(std::locale("C"));
	// Read name
	std::string name;
	std::getline(is, name, ' ');
	
	if(name == "MaterialItem")
	{
		// u16 reads directly as a number (u8 doesn't)
		u16 material;
		is>>material;
		u16 count;
		is>>count;
		if(material > MAX_CONTENT)
			throw SerializationError("Too large material number");
		return new MaterialItem(material, count);
	}
	else if(name == "MBOItem")
	{
		std::string inventorystring;
		std::getline(is, inventorystring, '|');
		return new MapBlockObjectItem(inventorystring);
	}
	else if(name == "CraftItem")
	{
		std::string subname;
		std::getline(is, subname, ' ');
		u16 count;
		is>>count;
		return new CraftItem(subname, count);
	}
	else if(name == "ToolItem")
	{
		std::string toolname;
		std::getline(is, toolname, ' ');
		u16 wear;
		is>>wear;
		return new ToolItem(toolname, wear);
	}
	else
	{
		dstream<<"Unknown InventoryItem name=\""<<name<<"\""<<std::endl;
		throw SerializationError("Unknown InventoryItem name");
	}
}

ServerActiveObject* InventoryItem::createSAO(ServerEnvironment *env, u16 id, v3f pos)
{
	/*
		Create an ItemSAO
	*/
	// Get item string
	std::ostringstream os(std::ios_base::binary);
	serialize(os);
	// Create object
	ServerActiveObject *obj = new ItemSAO(env, 0, pos, os.str());
	return obj;
}

/*
	MaterialItem
*/

bool MaterialItem::isCookable()
{
	return item_material_is_cookable(m_content);
}

InventoryItem *MaterialItem::createCookResult()
{
	return item_material_create_cook_result(m_content);
}

/*
	CraftItem
*/

#ifndef SERVER
video::ITexture * CraftItem::getImage()
{
	if(g_texturesource == NULL)
		return NULL;
	
	std::string name = item_craft_get_image_name(m_subname);

	// Get such a texture
	return g_texturesource->getTextureRaw(name);
}
#endif

ServerActiveObject* CraftItem::createSAO(ServerEnvironment *env, u16 id, v3f pos)
{
	// Special cases
	ServerActiveObject *obj = item_craft_create_object(m_subname, env, id, pos);
	if(obj)
		return obj;
	// Default
	return InventoryItem::createSAO(env, id, pos);
}

u16 CraftItem::getDropCount()
{
	// Special cases
	s16 dc = item_craft_get_drop_count(m_subname);
	if(dc != -1)
		return dc;
	// Default
	return InventoryItem::getDropCount();
}

bool CraftItem::isCookable()
{
	return item_craft_is_cookable(m_subname);
}

InventoryItem *CraftItem::createCookResult()
{
	return item_craft_create_cook_result(m_subname);
}

bool CraftItem::use(ServerEnvironment *env, Player *player)
{
	if(item_craft_is_eatable(m_subname))
	{
		s16 hp_change = item_craft_eat_hp_change(m_subname);
		if(player->hp + hp_change > 20)
			player->hp = 20;
		else
			player->hp += hp_change;
		return true;
	}
	return false;
}

/*
	MapBlockObjectItem DEPRECATED
	TODO: Remove
*/
#ifndef SERVER
video::ITexture * MapBlockObjectItem::getImage()
{
	if(m_inventorystring.substr(0,3) == "Rat")
		return g_texturesource->getTextureRaw("rat.png");
	
	if(m_inventorystring.substr(0,4) == "Sign")
		return g_texturesource->getTextureRaw("sign.png");

	return NULL;
}
#endif
std::string MapBlockObjectItem::getText()
{
	if(m_inventorystring.substr(0,3) == "Rat")
		return "";
	
	if(m_inventorystring.substr(0,4) == "Sign")
		return "";

	return "obj";
}

MapBlockObject * MapBlockObjectItem::createObject
		(v3f pos, f32 player_yaw, f32 player_pitch)
{
	std::istringstream is(m_inventorystring);
	std::string name;
	std::getline(is, name, ' ');
	
	if(name == "None")
	{
		return NULL;
	}
	else if(name == "Sign")
	{
		std::string text;
		std::getline(is, text, '|');
		SignObject *obj = new SignObject(NULL, -1, pos);
		obj->setText(text);
		obj->setYaw(-player_yaw);
		return obj;
	}
	else if(name == "Rat")
	{
		RatObject *obj = new RatObject(NULL, -1, pos);
		return obj;
	}
	else if(name == "ItemObj")
	{
		/*
			Now we are an inventory item containing the serialization
			string of an object that contains the serialization
			string of an inventory item. Fuck this.
		*/
		//assert(0);
		dstream<<__FUNCTION_NAME<<": WARNING: Ignoring ItemObj "
				<<"because an item-object should never be inside "
				<<"an object-item."<<std::endl;
		return NULL;
	}
	else
	{
		return NULL;
	}
}

/*
	Inventory
*/

InventoryList::InventoryList(std::string name, u32 size)
{
	m_name = name;
	m_size = size;
	clearItems();
	//m_dirty = false;
}

InventoryList::~InventoryList()
{
	for(u32 i=0; i<m_items.size(); i++)
	{
		if(m_items[i])
			delete m_items[i];
	}
}

void InventoryList::clearItems()
{
	for(u32 i=0; i<m_items.size(); i++)
	{
		if(m_items[i])
			delete m_items[i];
	}

	m_items.clear();

	for(u32 i=0; i<m_size; i++)
	{
		m_items.push_back(NULL);
	}

	//setDirty(true);
}

void InventoryList::serialize(std::ostream &os)
{
	//os.imbue(std::locale("C"));
	
	for(u32 i=0; i<m_items.size(); i++)
	{
		InventoryItem *item = m_items[i];
		if(item != NULL)
		{
			os<<"Item ";
			item->serialize(os);
		}
		else
		{
			os<<"Empty";
		}
		os<<"\n";
	}

	os<<"EndInventoryList\n";
}

void InventoryList::deSerialize(std::istream &is)
{
	//is.imbue(std::locale("C"));

	clearItems();
	u32 item_i = 0;

	for(;;)
	{
		std::string line;
		std::getline(is, line, '\n');

		std::istringstream iss(line);
		//iss.imbue(std::locale("C"));

		std::string name;
		std::getline(iss, name, ' ');

		if(name == "EndInventoryList")
		{
			break;
		}
		// This is a temporary backwards compatibility fix
		else if(name == "end")
		{
			break;
		}
		else if(name == "Item")
		{
			if(item_i > getSize() - 1)
				throw SerializationError("too many items");
			InventoryItem *item = InventoryItem::deSerialize(iss);
			m_items[item_i++] = item;
		}
		else if(name == "Empty")
		{
			if(item_i > getSize() - 1)
				throw SerializationError("too many items");
			m_items[item_i++] = NULL;
		}
		else
		{
			throw SerializationError("Unknown inventory identifier");
		}
	}
}

InventoryList::InventoryList(const InventoryList &other)
{
	/*
		Do this so that the items get cloned. Otherwise the pointers
		in the array will just get copied.
	*/
	*this = other;
}

InventoryList & InventoryList::operator = (const InventoryList &other)
{
	m_name = other.m_name;
	m_size = other.m_size;
	clearItems();
	for(u32 i=0; i<other.m_items.size(); i++)
	{
		InventoryItem *item = other.m_items[i];
		if(item != NULL)
		{
			m_items[i] = item->clone();
		}
	}
	//setDirty(true);

	return *this;
}

std::string InventoryList::getName()
{
	return m_name;
}

u32 InventoryList::getSize()
{
	return m_items.size();
}

u32 InventoryList::getUsedSlots()
{
	u32 num = 0;
	for(u32 i=0; i<m_items.size(); i++)