diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index c5070b3a9..11fe594f5 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -38,37 +38,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -static critbit_tree cb_equipments = { 0 }; - -equipment *get_equipment(const char *eqname) -{ - const char *match; - equipment *eq = NULL; - - match = cb_find_str(&cb_equipments, eqname); - if (match) { - cb_get_kv(match, &eq, sizeof(eq)); - } - return eq; -} - -equipment *get_or_create_equipment(const char *eqname) -{ - equipment *eq = get_equipment(eqname); - if (!eq) { - size_t len; - char data[64]; - - eq = (equipment *)calloc(1, sizeof(equipment)); - eq->name = strdup(eqname); - - len = cb_new_kv(eqname, strlen(eqname), &eq, sizeof(eq), data); - assert(len <= sizeof(data)); - cb_insert(&cb_equipments, data, len); - } - return eq; -} - void equipment_setskill(equipment * eq, skill_t sk, const char *value) { if (eq != NULL) { @@ -231,6 +200,37 @@ void free_ls(void *arg) { free(ls); } +static critbit_tree cb_equipments = { 0 }; + +equipment *get_equipment(const char *eqname) +{ + const char *match; + equipment *eq = NULL; + + match = cb_find_str(&cb_equipments, eqname); + if (match) { + cb_get_kv(match, &eq, sizeof(eq)); + } + return eq; +} + +equipment *get_or_create_equipment(const char *eqname) +{ + equipment *eq = get_equipment(eqname); + if (!eq) { + size_t len; + char data[64]; + + eq = (equipment *)calloc(1, sizeof(equipment)); + eq->name = strdup(eqname); + + len = cb_new_kv(eqname, strlen(eqname), &eq, sizeof(eq), data); + assert(len <= sizeof(data)); + cb_insert(&cb_equipments, data, len); + } + return eq; +} + static void free_equipment(equipment *eq) { int i; free(eq->name); diff --git a/src/monsters.c b/src/monsters.c index 57b557999..ddc30ca4d 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -191,6 +192,7 @@ void monsters_desert(struct faction *monsters) int monster_attacks(unit * monster, bool rich_only) { + const race *rc_serpent = get_race(RC_SEASERPENT); if (monster->status < ST_AVOID) { region *r = monster->region; unit *u2; @@ -199,6 +201,12 @@ int monster_attacks(unit * monster, bool rich_only) for (u2 = r->units; u2; u2 = u2->next) { if (u2->faction != monster->faction && cansee(monster->faction, r, u2, 0) && !in_safe_building(u2, monster)) { int m = get_money(u2); + if (u_race(monster) == rc_serpent) { + /* attack bigger ships only */ + if (!u2->ship || u2->ship->type->cargo <= 50000) { + continue; + } + } if (!rich_only || m > 0) { order *ord = monster_attack(monster, u2); if (ord) {