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