forked from github/server
rename create_equipment function
This commit is contained in:
parent
e7a41a2017
commit
64e45248dc
|
@ -83,7 +83,7 @@ without prior permission by the authors of Eressea.
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define TOLUA_PKG(NAME) extern void tolua_##NAME##_open(lua_State * L)
|
#define TOLUA_PKG(NAME) void tolua_##NAME##_open(lua_State * L)
|
||||||
|
|
||||||
TOLUA_PKG(eressea);
|
TOLUA_PKG(eressea);
|
||||||
TOLUA_PKG(process);
|
TOLUA_PKG(process);
|
||||||
|
@ -328,7 +328,7 @@ static int tolua_addequipment(lua_State * L)
|
||||||
if (iname != NULL) {
|
if (iname != NULL) {
|
||||||
const struct item_type *itype = it_find(iname);
|
const struct item_type *itype = it_find(iname);
|
||||||
if (itype != NULL) {
|
if (itype != NULL) {
|
||||||
equipment_setitem(create_equipment(eqname), itype, value);
|
equipment_setitem(get_or_create_equipment(eqname), itype, value);
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,7 @@ static int tolua_equipment_setitem(lua_State * L)
|
||||||
if (iname != NULL) {
|
if (iname != NULL) {
|
||||||
const struct item_type *itype = it_find(iname);
|
const struct item_type *itype = it_find(iname);
|
||||||
if (itype != NULL) {
|
if (itype != NULL) {
|
||||||
equipment_setitem(create_equipment(eqname), itype, value);
|
equipment_setitem(get_or_create_equipment(eqname), itype, value);
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
static equipment *equipment_sets;
|
static equipment *equipment_sets;
|
||||||
|
|
||||||
equipment *create_equipment(const char *eqname)
|
equipment *get_or_create_equipment(const char *eqname)
|
||||||
{
|
{
|
||||||
equipment **eqp = &equipment_sets;
|
equipment **eqp = &equipment_sets;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ extern "C" {
|
||||||
|
|
||||||
void equipment_done(void);
|
void equipment_done(void);
|
||||||
|
|
||||||
struct equipment *create_equipment(const char *eqname);
|
struct equipment *get_or_create_equipment(const char *eqname);
|
||||||
struct equipment *get_equipment(const char *eqname);
|
struct equipment *get_equipment(const char *eqname);
|
||||||
|
|
||||||
void equipment_setitem(struct equipment *eq,
|
void equipment_setitem(struct equipment *eq,
|
||||||
|
|
|
@ -27,7 +27,7 @@ void test_equipment(CuTest * tc)
|
||||||
CuAssertPtrNotNull(tc, sp);
|
CuAssertPtrNotNull(tc, sp);
|
||||||
|
|
||||||
CuAssertPtrEquals(tc, 0, get_equipment("herpderp"));
|
CuAssertPtrEquals(tc, 0, get_equipment("herpderp"));
|
||||||
eq = create_equipment("herpderp");
|
eq = get_or_create_equipment("herpderp");
|
||||||
CuAssertPtrEquals(tc, eq, get_equipment("herpderp"));
|
CuAssertPtrEquals(tc, eq, get_equipment("herpderp"));
|
||||||
|
|
||||||
equipment_setitem(eq, it_horses, "1");
|
equipment_setitem(eq, it_horses, "1");
|
||||||
|
|
|
@ -1266,7 +1266,7 @@ add_subsets(xmlDocPtr doc, equipment * eq, xmlNodeSetPtr nsetSubsets)
|
||||||
assert(propValue != NULL);
|
assert(propValue != NULL);
|
||||||
eq->subsets[i].sets[set].chance = chance;
|
eq->subsets[i].sets[set].chance = chance;
|
||||||
eq->subsets[i].sets[set].set =
|
eq->subsets[i].sets[set].set =
|
||||||
create_equipment((const char *)propValue);
|
get_or_create_equipment((const char *)propValue);
|
||||||
xmlFree(propValue);
|
xmlFree(propValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1296,7 +1296,7 @@ static int parse_equipment(xmlDocPtr doc)
|
||||||
xmlChar *propName = xmlGetProp(node, BAD_CAST "name");
|
xmlChar *propName = xmlGetProp(node, BAD_CAST "name");
|
||||||
|
|
||||||
if (propName != NULL) {
|
if (propName != NULL) {
|
||||||
equipment *eq = create_equipment((const char *)propName);
|
equipment *eq = get_or_create_equipment((const char *)propName);
|
||||||
xmlXPathObjectPtr xpathResult;
|
xmlXPathObjectPtr xpathResult;
|
||||||
|
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
|
|
Loading…
Reference in New Issue