diff --git a/s/build b/s/build index ea0f5f3d0..1d580a349 100755 --- a/s/build +++ b/s/build @@ -5,8 +5,13 @@ while [ ! -d $ROOT/.git ]; do done [ -z "$BUILD" ] && BUILD=Debug - -[ -z "$JOBS" ] && [ "" != "which nproc" ] && JOBS=`nproc` +if [ -z "$JOBS" ] ; then + if [ -e /usr/sbin/sysctl ]; then + JOBS=`sysctl -n hw.ncpu` + else + JOBS=`nproc` + fi +fi DISTCC=`which distcc` if [ ! -z "$DISTCC" ] ; then JOBS=`distcc -j` diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 6589e002a..271045491 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -1,6 +1,7 @@ #include #include "spells/shipcurse.h" #include "monster.h" +#include "monsters.h" #include #include @@ -28,7 +29,6 @@ static int tolua_levitate_ship(lua_State * L) } extern void spawn_undead(void); -extern void spawn_dragons(void); extern void plan_monsters(struct faction *f); static int tolua_planmonsters(lua_State * L) diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 47e4a63b4..a95dbe4cb 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1470,12 +1470,12 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace, /* u->region auch */ u->hp = unit_max_hp(u) * number; - if (!dname) { - name_unit(u); - } - else { + if (dname) { u->_name = _strdup(dname); } + else if (urace->generate_name || playerrace(urace)) { + name_unit(u); + } if (creator) { attrib *a; diff --git a/src/monsters.c b/src/monsters.c index 2fc2fcde3..67bf9370d 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -20,6 +20,8 @@ #include #include +#include "monsters.h" + #include "economy.h" #include "chaos.h" #include "give.h" @@ -883,7 +885,16 @@ static int nrand(int start, int sub) return res; } -/** Drachen und Seeschlangen können entstehen */ +unit *spawn_seaserpent(region *r, faction *f) { + unit *u = create_unit(r, f, 1, get_race(RC_SEASERPENT), 0, NULL, NULL); + fset(u, UFL_ISNEW | UFL_MOVED); + equip_unit(u, get_equipment("monster_seaserpent")); + return u; +} + +/** + * Drachen und Seeschlangen können entstehen + */ void spawn_dragons(void) { region *r; @@ -892,13 +903,12 @@ void spawn_dragons(void) for (r = regions; r; r = r->next) { unit *u; - if (fval(r->terrain, SEA_REGION) && rng_int() % 10000 < 1) { - u = create_unit(r, monsters, 1, get_race(RC_SEASERPENT), 0, NULL, NULL); - fset(u, UFL_ISNEW | UFL_MOVED); - equip_unit(u, get_equipment("monster_seaserpent")); + if (fval(r->terrain, SEA_REGION)) { + if (rng_int() % 10000 < 1) { + u = spawn_seaserpent(r, monsters); + } } - - if ((r->terrain == newterrain(T_GLACIER) + else if ((r->terrain == newterrain(T_GLACIER) || r->terrain == newterrain(T_SWAMP) || r->terrain == newterrain(T_DESERT)) && rng_int() % 10000 < (5 + 100 * chaosfactor(r))) { diff --git a/src/monsters.h b/src/monsters.h new file mode 100644 index 000000000..02e41c0a4 --- /dev/null +++ b/src/monsters.h @@ -0,0 +1,8 @@ +#pragma once + +struct unit; +struct region; +struct faction; + +struct unit *spawn_seaserpent(struct region *r, struct faction *f); +void spawn_dragons(void); diff --git a/src/monsters.test.c b/src/monsters.test.c index dd69e6bdb..a44a354d9 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -11,6 +11,7 @@ #include #include "monster.h" +#include "monsters.h" #include "guard.h" #include "reports.h" #include "skill.h" @@ -244,10 +245,27 @@ static void test_monsters_learn_exp(CuTest * tc) test_cleanup(); } +static void test_spawn_seaserpent(CuTest *tc) { + region *r; + unit *u; + faction *f; + race *rc; + test_cleanup(); + rc = test_create_race("seaserpent"); + rc->flags |= RCF_NPC; + r = test_create_region(0, 0, 0); + f = test_create_faction(0); + u = spawn_seaserpent(r, f); + CuAssertPtrNotNull(tc, u); + CuAssertPtrEquals(tc, 0, u->_name); + test_cleanup(); +} + CuSuite *get_monsters_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_monsters_attack); + SUITE_ADD_TEST(suite, test_spawn_seaserpent); SUITE_ADD_TEST(suite, test_monsters_attack_ocean); SUITE_ADD_TEST(suite, test_seaserpent_piracy); SUITE_ADD_TEST(suite, test_monsters_waiting); diff --git a/tolua b/tolua index e53fe09e5..32cc6a3e7 160000 --- a/tolua +++ b/tolua @@ -1 +1 @@ -Subproject commit e53fe09e5789083698d2efb1fd36250efa700c34 +Subproject commit 32cc6a3e78238278bc5b1fb8566526558e5afdda