Do not expose CONTENT_* stuff in content_mapnode.h and use a name converter wrapper...
[oweals/minetest.git] / src / content_craft.cpp
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "content_craft.h"
21 #include "inventory.h"
22 #include "content_mapnode.h"
23 #include "player.h"
24 #include "mapnode.h" // For content_t
25 #include "gamedef.h"
26
27 /*
28         items: actually *items[9]
29         return value: allocates a new item, or returns NULL.
30 */
31 InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
32 {
33         INodeDefManager *ndef = gamedef->ndef();
34
35         // Wood
36         {
37                 ItemSpec specs[9];
38                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_TREE"));
39                 if(checkItemCombination(items, specs))
40                 {
41                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_WOOD"), 4);
42                 }
43         }
44
45         // Stick
46         {
47                 ItemSpec specs[9];
48                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
49                 if(checkItemCombination(items, specs))
50                 {
51                         return new CraftItem(gamedef, "Stick", 4);
52                 }
53         }
54
55         // Fence
56         {
57                 ItemSpec specs[9];
58                 specs[3] = ItemSpec(ITEM_CRAFT, "Stick");
59                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
60                 specs[5] = ItemSpec(ITEM_CRAFT, "Stick");
61                 specs[6] = ItemSpec(ITEM_CRAFT, "Stick");
62                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
63                 specs[8] = ItemSpec(ITEM_CRAFT, "Stick");
64                 if(checkItemCombination(items, specs))
65                 {
66                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_FENCE"), 2);
67                 }
68         }
69
70         // Sign
71         {
72                 ItemSpec specs[9];
73                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
74                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
75                 specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
76                 specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
77                 specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
78                 specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
79                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
80                 if(checkItemCombination(items, specs))
81                 {
82                         //return new MapBlockObjectItem(gamedef, "Sign");
83                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_SIGN_WALL"), 1);
84                 }
85         }
86
87         // Torch
88         {
89                 ItemSpec specs[9];
90                 specs[0] = ItemSpec(ITEM_CRAFT, "lump_of_coal");
91                 specs[3] = ItemSpec(ITEM_CRAFT, "Stick");
92                 if(checkItemCombination(items, specs))
93                 {
94                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 4);
95                 }
96         }
97
98         // Wooden pick
99         {
100                 ItemSpec specs[9];
101                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
102                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
103                 specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
104                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
105                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
106                 if(checkItemCombination(items, specs))
107                 {
108                         return new ToolItem(gamedef, "WPick", 0);
109                 }
110         }
111
112         // Stone pick
113         {
114                 ItemSpec specs[9];
115                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
116                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
117                 specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
118                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
119                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
120                 if(checkItemCombination(items, specs))
121                 {
122                         return new ToolItem(gamedef, "STPick", 0);
123                 }
124         }
125
126         // Steel pick
127         {
128                 ItemSpec specs[9];
129                 specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot");
130                 specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
131                 specs[2] = ItemSpec(ITEM_CRAFT, "steel_ingot");
132                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
133                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
134                 if(checkItemCombination(items, specs))
135                 {
136                         return new ToolItem(gamedef, "SteelPick", 0);
137                 }
138         }
139
140         // Mese pick
141         {
142                 ItemSpec specs[9];
143                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
144                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
145                 specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
146                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
147                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
148                 if(checkItemCombination(items, specs))
149                 {
150                         return new ToolItem(gamedef, "MesePick", 0);
151                 }
152         }
153
154         // Wooden shovel
155         {
156                 ItemSpec specs[9];
157                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
158                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
159                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
160                 if(checkItemCombination(items, specs))
161                 {
162                         return new ToolItem(gamedef, "WShovel", 0);
163                 }
164         }
165
166         // Stone shovel
167         {
168                 ItemSpec specs[9];
169                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
170                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
171                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
172                 if(checkItemCombination(items, specs))
173                 {
174                         return new ToolItem(gamedef, "STShovel", 0);
175                 }
176         }
177
178         // Steel shovel
179         {
180                 ItemSpec specs[9];
181                 specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
182                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
183                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
184                 if(checkItemCombination(items, specs))
185                 {
186                         return new ToolItem(gamedef, "SteelShovel", 0);
187                 }
188         }
189
190         // Wooden axe
191         {
192                 ItemSpec specs[9];
193                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
194                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
195                 specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
196                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
197                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
198                 if(checkItemCombination(items, specs))
199                 {
200                         return new ToolItem(gamedef, "WAxe", 0);
201                 }
202         }
203
204         // Stone axe
205         {
206                 ItemSpec specs[9];
207                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
208                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
209                 specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
210                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
211                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
212                 if(checkItemCombination(items, specs))
213                 {
214                         return new ToolItem(gamedef, "STAxe", 0);
215                 }
216         }
217
218         // Steel axe
219         {
220                 ItemSpec specs[9];
221                 specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot");
222                 specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
223                 specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot");
224                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
225                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
226                 if(checkItemCombination(items, specs))
227                 {
228                         return new ToolItem(gamedef, "SteelAxe", 0);
229                 }
230         }
231
232         // Wooden sword
233         {
234                 ItemSpec specs[9];
235                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
236                 specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
237                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
238                 if(checkItemCombination(items, specs))
239                 {
240                         return new ToolItem(gamedef, "WSword", 0);
241                 }
242         }
243
244         // Stone sword
245         {
246                 ItemSpec specs[9];
247                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
248                 specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
249                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
250                 if(checkItemCombination(items, specs))
251                 {
252                         return new ToolItem(gamedef, "STSword", 0);
253                 }
254         }
255
256         // Steel sword
257         {
258                 ItemSpec specs[9];
259                 specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
260                 specs[4] = ItemSpec(ITEM_CRAFT, "steel_ingot");
261                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
262                 if(checkItemCombination(items, specs))
263                 {
264                         return new ToolItem(gamedef, "SteelSword", 0);
265                 }
266         }
267
268         // Rail
269         {
270                 ItemSpec specs[9];
271                 specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot");
272                 specs[1] = ItemSpec(ITEM_CRAFT, "Stick");
273                 specs[2] = ItemSpec(ITEM_CRAFT, "steel_ingot");
274                 specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot");
275                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
276                 specs[5] = ItemSpec(ITEM_CRAFT, "steel_ingot");
277                 specs[6] = ItemSpec(ITEM_CRAFT, "steel_ingot");
278                 specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
279                 specs[8] = ItemSpec(ITEM_CRAFT, "steel_ingot");
280                 if(checkItemCombination(items, specs))
281                 {
282                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_RAIL"), 15);
283                 }
284         }
285
286         // Chest
287         {
288                 ItemSpec specs[9];
289                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
290                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
291                 specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
292                 specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
293                 specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
294                 specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
295                 specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
296                 specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
297                 if(checkItemCombination(items, specs))
298                 {
299                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_CHEST"), 1);
300                 }
301         }
302
303         // Locking Chest
304         {
305                 ItemSpec specs[9];
306                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
307                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
308                 specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
309                 specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
310                 specs[4] = ItemSpec(ITEM_CRAFT, "steel_ingot");
311                 specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
312                 specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
313                 specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
314                 specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
315                 if(checkItemCombination(items, specs))
316                 {
317                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_LOCKABLE_CHEST"), 1);
318                 }
319         }
320
321         // Furnace
322         {
323                 ItemSpec specs[9];
324                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
325                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
326                 specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
327                 specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
328                 specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
329                 specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
330                 specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
331                 specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
332                 if(checkItemCombination(items, specs))
333                 {
334                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_FURNACE"), 1);
335                 }
336         }
337
338         // Steel block
339         {
340                 ItemSpec specs[9];
341                 specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot");
342                 specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
343                 specs[2] = ItemSpec(ITEM_CRAFT, "steel_ingot");
344                 specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot");
345                 specs[4] = ItemSpec(ITEM_CRAFT, "steel_ingot");
346                 specs[5] = ItemSpec(ITEM_CRAFT, "steel_ingot");
347                 specs[6] = ItemSpec(ITEM_CRAFT, "steel_ingot");
348                 specs[7] = ItemSpec(ITEM_CRAFT, "steel_ingot");
349                 specs[8] = ItemSpec(ITEM_CRAFT, "steel_ingot");
350                 if(checkItemCombination(items, specs))
351                 {
352                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_STEEL"), 1);
353                 }
354         }
355
356         // Sandstone
357         {
358                 ItemSpec specs[9];
359                 specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
360                 specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
361                 specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
362                 specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
363                 if(checkItemCombination(items, specs))
364                 {
365                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_SANDSTONE"), 1);
366                 }
367         }
368
369         // Clay
370         {
371                 ItemSpec specs[9];
372                 specs[3] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
373                 specs[4] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
374                 specs[6] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
375                 specs[7] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
376                 if(checkItemCombination(items, specs))
377                 {
378                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_CLAY"), 1);
379                 }
380         }
381
382         // Brick
383         {
384                 ItemSpec specs[9];
385                 specs[3] = ItemSpec(ITEM_CRAFT, "clay_brick");
386                 specs[4] = ItemSpec(ITEM_CRAFT, "clay_brick");
387                 specs[6] = ItemSpec(ITEM_CRAFT, "clay_brick");
388                 specs[7] = ItemSpec(ITEM_CRAFT, "clay_brick");
389                 if(checkItemCombination(items, specs))
390                 {
391                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_BRICK"), 1);
392                 }
393         }
394
395         // Paper
396         {
397                 ItemSpec specs[9];
398                 specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
399                 specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
400                 specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
401                 if(checkItemCombination(items, specs))
402                 {
403                         return new CraftItem(gamedef, "paper", 1);
404                 }
405         }
406
407         // Book
408         {
409                 ItemSpec specs[9];
410                 specs[1] = ItemSpec(ITEM_CRAFT, "paper");
411                 specs[4] = ItemSpec(ITEM_CRAFT, "paper");
412                 specs[7] = ItemSpec(ITEM_CRAFT, "paper");
413                 if(checkItemCombination(items, specs))
414                 {
415                         return new CraftItem(gamedef, "book", 1);
416                 }
417         }
418
419         // Book shelf
420         {
421                 ItemSpec specs[9];
422                 specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
423                 specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
424                 specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
425                 specs[3] = ItemSpec(ITEM_CRAFT, "book");
426                 specs[4] = ItemSpec(ITEM_CRAFT, "book");
427                 specs[5] = ItemSpec(ITEM_CRAFT, "book");
428                 specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
429                 specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
430                 specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
431                 if(checkItemCombination(items, specs))
432                 {
433                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_BOOKSHELF"), 1);
434                 }
435         }
436
437         // Ladder
438         {
439                 ItemSpec specs[9];
440                 specs[0] = ItemSpec(ITEM_CRAFT, "Stick");
441                 specs[2] = ItemSpec(ITEM_CRAFT, "Stick");
442                 specs[3] = ItemSpec(ITEM_CRAFT, "Stick");
443                 specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
444                 specs[5] = ItemSpec(ITEM_CRAFT, "Stick");
445                 specs[6] = ItemSpec(ITEM_CRAFT, "Stick");
446                 specs[8] = ItemSpec(ITEM_CRAFT, "Stick");
447                 if(checkItemCombination(items, specs))
448                 {
449                         return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_LADDER"), 1);
450                 }
451         }
452         
453         // Iron Apple
454         {
455                 ItemSpec specs[9];
456                 specs[1] = ItemSpec(ITEM_CRAFT, "steel_ingot");
457                 specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot");
458                 specs[4] = ItemSpec(ITEM_CRAFT, "apple");
459                 specs[5] = ItemSpec(ITEM_CRAFT, "steel_ingot");
460                 specs[7] = ItemSpec(ITEM_CRAFT, "steel_ingot");
461                 if(checkItemCombination(items, specs))
462                 {
463                         return new CraftItem(gamedef, "apple_iron", 1);
464                 }
465         }
466
467         return NULL;
468 }
469
470 void craft_set_creative_inventory(Player *player, IGameDef *gamedef)
471 {
472         INodeDefManager *ndef = gamedef->ndef();
473
474         player->resetInventory();
475         
476         // Give some good tools
477         {
478                 InventoryItem *item = new ToolItem(gamedef, "MesePick", 0);
479                 void* r = player->inventory.addItem("main", item);
480                 assert(r == NULL);
481         }
482         {
483                 InventoryItem *item = new ToolItem(gamedef, "SteelPick", 0);
484                 void* r = player->inventory.addItem("main", item);
485                 assert(r == NULL);
486         }
487         {
488                 InventoryItem *item = new ToolItem(gamedef, "SteelAxe", 0);
489                 void* r = player->inventory.addItem("main", item);
490                 assert(r == NULL);
491         }
492         {
493                 InventoryItem *item = new ToolItem(gamedef, "SteelShovel", 0);
494                 void* r = player->inventory.addItem("main", item);
495                 assert(r == NULL);
496         }
497
498         /*
499                 Give materials
500         */
501         
502         // CONTENT_IGNORE-terminated list
503         content_t material_items[] = {
504                 LEGN(ndef, "CONTENT_TORCH"),
505                 LEGN(ndef, "CONTENT_COBBLE"),
506                 LEGN(ndef, "CONTENT_MUD"),
507                 LEGN(ndef, "CONTENT_STONE"),
508                 LEGN(ndef, "CONTENT_SAND"),
509                 LEGN(ndef, "CONTENT_SANDSTONE"),
510                 LEGN(ndef, "CONTENT_CLAY"),
511                 LEGN(ndef, "CONTENT_BRICK"),
512                 LEGN(ndef, "CONTENT_TREE"),
513                 LEGN(ndef, "CONTENT_LEAVES"),
514                 LEGN(ndef, "CONTENT_CACTUS"),
515                 LEGN(ndef, "CONTENT_PAPYRUS"),
516                 LEGN(ndef, "CONTENT_BOOKSHELF"),
517                 LEGN(ndef, "CONTENT_GLASS"),
518                 LEGN(ndef, "CONTENT_FENCE"),
519                 LEGN(ndef, "CONTENT_RAIL"),
520                 LEGN(ndef, "CONTENT_MESE"),
521                 LEGN(ndef, "CONTENT_WATERSOURCE"),
522                 LEGN(ndef, "CONTENT_CLOUD"),
523                 LEGN(ndef, "CONTENT_CHEST"),
524                 LEGN(ndef, "CONTENT_FURNACE"),
525                 LEGN(ndef, "CONTENT_SIGN_WALL"),
526                 LEGN(ndef, "CONTENT_LAVASOURCE"),
527                 CONTENT_IGNORE
528         };
529         
530         content_t *mip = material_items;
531         for(u16 i=0; i<PLAYER_INVENTORY_SIZE; i++)
532         {
533                 if(*mip == CONTENT_IGNORE)
534                         break;
535
536                 InventoryItem *item = new MaterialItem(gamedef, *mip, 1);
537                 player->inventory.addItem("main", item);
538
539                 mip++;
540         }
541
542 #if 0
543         assert(USEFUL_LEGN(ndef, "CONTENT_COUNT") <= PLAYER_INVENTORY_SIZE);
544         
545         // add torch first
546         InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 1);
547         player->inventory.addItem("main", item);
548         
549         // Then others
550         for(u16 i=0; i<USEFUL_LEGN(ndef, "CONTENT_COUNT"); i++)
551         {
552                 // Skip some materials
553                 if(i == LEGN(ndef, "CONTENT_WATER") || i == LEGN(ndef, "CONTENT_TORCH")
554                         || i == LEGN(ndef, "CONTENT_COALSTONE"))
555                         continue;
556
557                 InventoryItem *item = new MaterialItem(gamedef, i, 1);
558                 player->inventory.addItem("main", item);
559         }
560 #endif
561
562         /*// Sign
563         {
564                 InventoryItem *item = new MapBlockObjectItem(gamedef, "Sign Example text");
565                 void* r = player->inventory.addItem("main", item);
566                 assert(r == NULL);
567         }*/
568 }
569
570 void craft_give_initial_stuff(Player *player, IGameDef *gamedef)
571 {
572         INodeDefManager *ndef = gamedef->ndef();
573
574         {
575                 InventoryItem *item = new ToolItem(gamedef, "SteelPick", 0);
576                 void* r = player->inventory.addItem("main", item);
577                 assert(r == NULL);
578         }
579         {
580                 InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 99);
581                 void* r = player->inventory.addItem("main", item);
582                 assert(r == NULL);
583         }
584         {
585                 InventoryItem *item = new ToolItem(gamedef, "SteelAxe", 0);
586                 void* r = player->inventory.addItem("main", item);
587                 assert(r == NULL);
588         }
589         {
590                 InventoryItem *item = new ToolItem(gamedef, "SteelShovel", 0);
591                 void* r = player->inventory.addItem("main", item);
592                 assert(r == NULL);
593         }
594         {
595                 InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_COBBLE"), 99);
596                 void* r = player->inventory.addItem("main", item);
597                 assert(r == NULL);
598         }
599         /*{
600                 InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_MESE"), 6);
601                 void* r = player->inventory.addItem("main", item);
602                 assert(r == NULL);
603         }
604         {
605                 InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_COALSTONE"), 6);
606                 void* r = player->inventory.addItem("main", item);
607                 assert(r == NULL);
608         }
609         {
610                 InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_WOOD"), 6);
611                 void* r = player->inventory.addItem("main", item);
612                 assert(r == NULL);
613         }
614         {
615                 InventoryItem *item = new CraftItem(gamedef, "Stick", 4);
616                 void* r = player->inventory.addItem("main", item);
617                 assert(r == NULL);
618         }
619         {
620                 InventoryItem *item = new ToolItem(gamedef, "WPick", 32000);
621                 void* r = player->inventory.addItem("main", item);
622                 assert(r == NULL);
623         }
624         {
625                 InventoryItem *item = new ToolItem(gamedef, "STPick", 32000);
626                 void* r = player->inventory.addItem("main", item);
627                 assert(r == NULL);
628         }*/
629         /*// and some signs
630         for(u16 i=0; i<4; i++)
631         {
632                 InventoryItem *item = new MapBlockObjectItem(gamedef, "Sign Example text");
633                 bool r = player->inventory.addItem("main", item);
634                 assert(r == true);
635         }*/
636         /*// Give some other stuff
637         {
638                 InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TREE"), 999);
639                 bool r = player->inventory.addItem("main", item);
640                 assert(r == true);
641         }*/
642 }
643