… | |
… | |
75 | weight = 100; |
75 | weight = 100; |
76 | value = 100; |
76 | value = 100; |
77 | density = 1000; |
77 | density = 1000; |
78 | } |
78 | } |
79 | |
79 | |
|
|
80 | // create a new material of the given name |
|
|
81 | static materialtype_t * |
|
|
82 | dummy_material (shstr_tmp name) |
|
|
83 | { |
|
|
84 | materialtype_t *mt = new materialtype_t; |
|
|
85 | mt->name = name; |
|
|
86 | |
|
|
87 | // make it susceptible to attacks |
|
|
88 | for (int i = 0; i < NROFATTACKS; i++) |
|
|
89 | { |
|
|
90 | mt->save [i] = 10; |
|
|
91 | mt->mod [i] = 9; |
|
|
92 | } |
|
|
93 | |
|
|
94 | mt->next = materialt; materialt = mt; |
|
|
95 | |
|
|
96 | return mt; |
|
|
97 | } |
|
|
98 | |
80 | /* convert materialname to materialtype_t */ |
99 | /* convert materialname to materialtype_t */ |
81 | materialtype_t * |
100 | materialtype_t * |
82 | name_to_material (const shstr_tmp name) |
101 | name_to_material (const shstr_tmp name) |
83 | { |
102 | { |
84 | for (materialtype_t *mt = materialt; mt; mt = mt->next) |
103 | for (materialtype_t *mt = materialt; mt; mt = mt->next) |
85 | if (name == mt->name) |
104 | if (name == mt->name) |
86 | return mt; |
105 | return mt; |
87 | |
106 | |
88 | LOG (llevError, "name_to_material called with nonexistent material '%s'\n", &name); |
107 | LOG (llevError, "name_to_material called with nonexistent material '%s'\n", &name); |
89 | |
108 | |
90 | // create a new material of the given name |
109 | return dummy_material (name); |
91 | materialtype_t *mt = new materialtype_t; |
110 | } |
92 | mt->name = name; |
|
|
93 | |
111 | |
94 | // make it susceptible to attacks |
112 | void |
95 | for (int i = 0; i < NROFATTACKS; i++) |
113 | object_thawer::get (materialtype_t *&m) const |
|
|
114 | { |
|
|
115 | shstr name; |
|
|
116 | get (name); |
|
|
117 | |
|
|
118 | for (materialtype_t *mt = materialt; mt; mt = mt->next) |
|
|
119 | if (name == mt->name) |
96 | { |
120 | { |
97 | mt->save [i] = 10; |
121 | m = mt; |
98 | mt->mod [i] = 9; |
122 | return; |
99 | } |
123 | } |
100 | |
124 | |
101 | mt->next = materialt; materialt = mt; |
125 | parse_error (format ("material called %s requested, but not found, creating dummy material.\n", &name)); |
102 | |
126 | |
103 | return mt; |
127 | m = dummy_material (name); |
104 | } |
128 | } |
105 | |
129 | |
106 | /* when doing transmutation of objects, we have to recheck the resistances, |
130 | /* when doing transmutation of objects, we have to recheck the resistances, |
107 | * as some that did not apply previously, may apply now. |
131 | * as some that did not apply previously, may apply now. |
108 | */ |
132 | */ |