forked from github/server
- fixed counting of group members
- fixed maximum size of region names. - fixed animals
This commit is contained in:
parent
9715493071
commit
b43220dbed
6 changed files with 55 additions and 41 deletions
|
@ -132,34 +132,48 @@ free_group(group * g)
|
|||
free(g);
|
||||
}
|
||||
|
||||
boolean
|
||||
join_group(unit * u, const char * name)
|
||||
void
|
||||
set_group(struct unit * u, struct group * g)
|
||||
{
|
||||
attrib * a = NULL;
|
||||
group * g;
|
||||
attrib * a = NULL;
|
||||
|
||||
if (fval(u, UFL_GROUP)) {
|
||||
a = a_find(u->attribs, &at_group);
|
||||
}
|
||||
|
||||
if (a) ((group *)(a->data.v))->members--;
|
||||
if (!name || !strlen(name)) {
|
||||
if (a) {
|
||||
a_remove(&u->attribs, a);
|
||||
freset(u, UFL_GROUP);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
g = find_groupbyname(u->faction->groups, name);
|
||||
if (!g) {
|
||||
g = new_group(u->faction, name, ++maxgid);
|
||||
init_group(u->faction, g);
|
||||
}
|
||||
if (!a) {
|
||||
a = a_add(&u->attribs, a_new(&at_group));
|
||||
fset(u, UFL_GROUP);
|
||||
if (a) {
|
||||
group * og = (group *)a->data.v;
|
||||
if (og==g) return;
|
||||
--og->members;
|
||||
}
|
||||
a->data.v = g;
|
||||
g->members++;
|
||||
|
||||
if (g) {
|
||||
if (!a) {
|
||||
a = a_add(&u->attribs, a_new(&at_group));
|
||||
fset(u, UFL_GROUP);
|
||||
}
|
||||
a->data.v = g;
|
||||
g->members++;
|
||||
} else if (a) {
|
||||
a_remove(&u->attribs, a);
|
||||
freset(u, UFL_GROUP);
|
||||
}
|
||||
}
|
||||
|
||||
boolean
|
||||
join_group(unit * u, const char * name)
|
||||
{
|
||||
group * g = NULL;
|
||||
|
||||
if (name && name[0]) {
|
||||
g = find_groupbyname(u->faction->groups, name);
|
||||
if (g==NULL) {
|
||||
g = new_group(u->faction, name, ++maxgid);
|
||||
init_group(u->faction, g);
|
||||
}
|
||||
}
|
||||
|
||||
set_group(u, g);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef struct group {
|
|||
|
||||
extern struct attrib_type at_group; /* attribute for units assigned to a group */
|
||||
extern boolean join_group(struct unit * u, const char * name);
|
||||
extern void set_group(struct unit * u, struct group * g);
|
||||
extern void free_group(struct group * g);
|
||||
|
||||
extern void write_groups(FILE * F, struct group * g);
|
||||
|
|
|
@ -121,7 +121,7 @@ write_regionname(const region * r, const faction * f, char * buffer, size_t size
|
|||
region_x(r, f), region_y(r, f));
|
||||
}
|
||||
}
|
||||
buf[64] = 0;
|
||||
buf[size-1] = 0;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -1370,8 +1370,7 @@ create_unit(region * r, faction * f, int number, const struct race *urace, int i
|
|||
a = a_find(creator->attribs, &at_group);
|
||||
if (a) {
|
||||
group * g = (group*)a->data.v;
|
||||
a_add(&u->attribs, a_new(&at_group))->data.v = g;
|
||||
fset(u, UFL_GROUP);
|
||||
set_group(u, g);
|
||||
}
|
||||
}
|
||||
a = a_find(creator->attribs, &at_otherfaction);
|
||||
|
|
|
@ -17,7 +17,7 @@ for k,v in project.configs do
|
|||
table.insert(package.config[v].defines, "WIN32")
|
||||
table.insert(package.config[v].defines, "_CRT_SECURE_NO_DEPRECATE")
|
||||
end
|
||||
if v=="Release" then
|
||||
if v~="Debug" then
|
||||
table.insert(package.config[v].defines, "NDEBUG")
|
||||
end
|
||||
end
|
||||
|
@ -44,7 +44,7 @@ for k,v in project.configs do
|
|||
table.insert(package.config[v].defines, "WIN32")
|
||||
table.insert(package.config[v].defines, "_CRT_SECURE_NO_DEPRECATE")
|
||||
end
|
||||
if v=="Release" then
|
||||
if v~="Debug" then
|
||||
table.insert(package.config[v].defines, "NDEBUG")
|
||||
end
|
||||
end
|
||||
|
@ -65,7 +65,7 @@ for k,v in project.configs do
|
|||
table.insert(package.config[v].defines, "WIN32")
|
||||
table.insert(package.config[v].defines, "_CRT_SECURE_NO_DEPRECATE")
|
||||
end
|
||||
if v=="Release" then
|
||||
if v~="Debug" then
|
||||
table.insert(package.config[v].defines, "NDEBUG")
|
||||
end
|
||||
end
|
||||
|
@ -87,7 +87,7 @@ for k,v in project.configs do
|
|||
table.insert(package.config[v].defines, "WIN32")
|
||||
table.insert(package.config[v].defines, "_CRT_SECURE_NO_DEPRECATE")
|
||||
end
|
||||
if v=="Release" then
|
||||
if v~="Debug" then
|
||||
table.insert(package.config[v].defines, "NDEBUG")
|
||||
end
|
||||
end
|
||||
|
@ -112,9 +112,7 @@ for k,v in project.configs do
|
|||
package.config[v].links = { "lua5.1_d", "luabind_d" }
|
||||
else
|
||||
package.config[v].links = { "lua5.1", "luabind" }
|
||||
if v=="Release" then
|
||||
table.insert(package.config[v].defines, "NDEBUG")
|
||||
end
|
||||
table.insert(package.config[v].defines, "NDEBUG")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -139,9 +137,7 @@ for k,v in project.configs do
|
|||
package.config[v].links = { "lua5.1_d", "luabind_d" }
|
||||
else
|
||||
package.config[v].links = { "lua5.1", "luabind" }
|
||||
if v=="Release" then
|
||||
table.insert(package.config[v].defines, "NDEBUG")
|
||||
end
|
||||
table.insert(package.config[v].defines, "NDEBUG")
|
||||
end
|
||||
-- package.config["Debug"].linkoptions = { "/NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMT" }
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<item weight="100" score="6000"/>
|
||||
</resource>
|
||||
|
||||
<resource name="sphereofinv">
|
||||
<resource name="sphereofinv" appearance="">
|
||||
<item weight="100" score="6000"/>
|
||||
</resource>
|
||||
|
||||
|
@ -66,15 +66,15 @@
|
|||
</resource>
|
||||
|
||||
<resource name="pegasus">
|
||||
<item weight="5000" notlost="yes" big="yes" score="6000" capacity="7000"/>
|
||||
<item weight="5000" notlost="yes" big="yes" score="6000" capacity="7000" animal="yes"/>
|
||||
</resource>
|
||||
|
||||
<resource name="elvenhorse">
|
||||
<item weight="5000" notlost="yes" big="yes" score="6000" capacity="7000"/>
|
||||
<item weight="5000" notlost="yes" big="yes" score="6000" capacity="7000" animal="yes"/>
|
||||
</resource>
|
||||
|
||||
<resource name="dolphin">
|
||||
<item weight="5000" notlost="yes" big="yes" score="6000" capacity="7000"/>
|
||||
<item weight="5000" notlost="yes" big="yes" score="6000" capacity="7000" animal="yes"/>
|
||||
</resource>
|
||||
|
||||
<resource name="iron" limited="yes">
|
||||
|
@ -83,6 +83,8 @@
|
|||
</item>
|
||||
<resourcelimit>
|
||||
<modifier building="mine" type="skill" value="1"/>
|
||||
<modifier building="mine" type="material" value="0.5"/>
|
||||
<modifier race="dwarf" type="material" value="0.75"/>
|
||||
<guard flag="mining"/>
|
||||
</resourcelimit>
|
||||
</resource>
|
||||
|
@ -97,16 +99,18 @@
|
|||
</resource>
|
||||
|
||||
<resource name="stone" limited="yes">
|
||||
<item weight="6000" score="10" big="yes" animal="yes">
|
||||
<item weight="6000" score="10" big="yes">
|
||||
<construction skill="quarrying" minskill="1" reqsize="1"/>
|
||||
</item>
|
||||
<resourcelimit>
|
||||
<modifier building="quarry" type="skill" value="1"/>
|
||||
<modifier building="quarry" type="material" value="0.5"/>
|
||||
<modifier race="troll" type="material" value="0.75"/>
|
||||
</resourcelimit>
|
||||
</resource>
|
||||
|
||||
<resource name="horse" limited="yes">
|
||||
<item weight="5000" score="10" capacity="7000">
|
||||
<item weight="5000" score="10" capacity="7000" animal="yes">
|
||||
<construction skill="training" minskill="1" reqsize="1"/>
|
||||
</item>
|
||||
<resourcelimit>
|
||||
|
|
Loading…
Reference in a new issue