Go to the documentation of this file.
54 static int reference_number = 0;
60 for (exit_ob =
GET_MAP_OB(
map,
x,
y); exit_ob != NULL; exit_ob = exit_ob->above)
61 if (exit_ob->type ==
EXIT && exit_ob->msg != NULL)
71 memset(&rp, 0,
sizeof(
RMParms));
97 snprintf(
buf,
sizeof(
buf),
"%s", cp);
98 while (isdigit(
buf[strlen(
buf)-1]))
102 snprintf(newmap_name,
sizeof(newmap_name),
"/random/%s%04d", cp+1, reference_number++);
107 static void do_run(
void) {
111 int iteration,
x,
y,
map;
116 snprintf(
path,
sizeof(
path),
"/whalingoutpost/underwaterdungeon/level%d",
map);
118 fail_unless(worldmap != NULL,
"Can't load %s",
path);
123 while (random != NULL) {
124 random = get_random_map(random);
135 fail_unless(
check->inv != NULL,
"Horn has empty inventory!");
140 fail_unless(iteration != 0,
"did %d iterations", iteration);
148 static void do_run(
void) {
154 fail_unless(overlay != NULL,
"Couldn't load unique map ../../rsc/bug_1727944_unique");
156 while (
found == 0 && test < 10) {
158 fail_unless(
map != NULL,
"couldn't load map ../../rsc/bug_1727944");
164 fail_unless(
check->inv != NULL,
"Horn has empty inventory!");
165 fail_unless(
check->inv->below == NULL,
"Horn has 2 items in inventory!");
166 if (
check->title && strcmp(
check->title,
"of Plenty") == 0) {
203 if (
op->arch &&
op->name !=
op->arch->clone.name &&
op->name_pl ==
op->arch->clone.name_pl) {
208 if (!
op->name_pl &&
op->name)
223 }
else if ((!strcmp(
op->skill,
"one handed weapons") &&
op->body_info[1] != -1)
224 || (!strcmp(
op->skill,
"two handed weapons") &&
op->body_info[1] != -2)) {
225 LOG(
llevError,
"weapon %s arm usage does not match skill: %d, %s\n",
226 op->name,
op->body_info[1],
op->skill);
246 LOG(
llevDebug,
"Object %s still has last_heal set, not gen_sp_armour\n",
op->name ?
op->name :
"NULL");
247 op->gen_sp_armour =
op->last_heal;
252 if (!
op->item_power &&
ip) {
254 LOG(
llevDebug,
"Object %s had no item power, using %d\n",
op->name ?
op->name :
"NULL",
ip);
264 if (
ip > 2*
op->item_power &&
ip > (
op->item_power+3)) {
265 LOG(
llevDebug,
"Object %s seems to have too low item power? %d > %d\n",
op->name ?
op->name :
"NULL",
ip,
op->item_power);
279 op->randomitems = NULL;
288 op->randomitems = NULL;
290 op->value =
op->arch->clone.value*
op->inv->value;
294 if (
op->stats.hp >
op->stats.maxhp)
295 LOG(
llevDebug,
"Monster %s has hp set higher than maxhp (%d>%d)\n",
op->name,
op->stats.hp,
op->stats.maxhp);
315 temp->reference_count++;
317 temp->tail_x =
op->arch->tail_x;
318 temp->tail_y =
op->arch->tail_y;
320 temp->clone.inv = NULL;
321 temp->clone.env = NULL;
324 temp->clone.map = NULL;
332 temp->clone.speed = 0;
334 temp->clone.speed =
op->speed;
337 temp->more =
op->arch->more;
349 for (test = 0; test < 50; test++)
352 for (test = 0; test < 50; test++) {
354 fail_unless(overlay != NULL,
"Couldn't load unique map ../../rsc/bug_1727944_unique");
355 fail_unless(
GET_MAP_OB(overlay, 2, 3) != NULL,
"No item on spot 2,3?");
358 fail_unless(
check->type ==
ROD,
"Found a non horn?");
359 fail_unless(
check->inv != NULL,
"Horn without a spell!");
360 fail_unless(
check->inv->below == NULL,
"Horn with 2 items in inventory.");
370 fail_unless(horn != NULL,
"couldn't find archetype horn.");
372 fail_unless(horn2 != NULL,
"couldn't find archetype horn2.");
374 for (test = 0; test < 100000; test++) {
378 fail_unless(
check->inv != NULL,
"horn without inventory!");
383 object *the_chest, *
check;
386 fail_unless(tlist != NULL,
"couldn't find treasure list uncommon_items");
388 for (test = 0; test < 10; test++) {
391 fail_unless(
map != NULL,
"failed to get empty map");
395 fail_unless(the_chest != NULL,
"failed to get chest");
401 fail_unless(the_chest != NULL,
"failed to recover chest?");
406 fail_unless(
check->inv != NULL,
"horn without inventory");
407 fail_unless(
check->inv->below == NULL,
"horn with 2 items");
408 fail_unless(
check->randomitems == NULL,
"horn with randomitems set");
414 fail_unless(
found > 100,
"didn't find 100 horn but %d??",
found);
420 Suite *s = suite_create(
"bug");
421 TCase *tc_core = tcase_create(
"Core");
426 suite_add_tcase(s, tc_core);
427 tcase_add_test(tc_core, test_randommaps);
428 tcase_set_timeout(tc_core, 0);
436 SRunner *sr = srunner_create(s);
438 srunner_set_fork_status(sr, CK_NOFORK);
442 srunner_set_xml(sr, LOGDIR
"/bugs/bugtrack/1727944.xml");
443 srunner_set_log(sr, LOGDIR
"/bugs/bugtrack/1727944.out");
444 srunner_run_all(sr, CK_ENV);
445 nf = srunner_ntests_failed(sr);
447 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
static END_TEST Suite * bug_suite(void)
#define GET_MAP_OB(M, X, Y)
mapstruct * ready_map_name(const char *name, int flags)
sstring add_string(const char *str)
void object_remove(object *op)
#define QUERY_FLAG(xyz, p)
archetype * get_archetype_struct(void)
#define FLAG_CONTENT_ON_GEN
static void teardown(void)
int calc_item_power(const object *op)
void set_materialname(object *op)
int set_random_map_variable(RMParms *rp, const char *buf)
void object_set_flag_inv(object *op, int flag)
int object_can_merge(object *ob1, object *ob2)
#define MAP_PLAYER_UNIQUE
treasurelist * find_treasurelist(const char *name)
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout, sstring reset_group)
struct treasureliststruct * randomitems
#define SAVE_MODE_OVERLAY
#define FLAG_IS_A_TEMPLATE
void free_string(sstring str)
void apply_auto_fix(mapstruct *m)
void object_copy(const object *src_ob, object *dest_ob)
void generate_artifact(object *op, int difficulty)
struct regiondef * region
void delete_map(mapstruct *m)
object * create_archetype(const char *name)
int save_map(mapstruct *m, int flag)
void LOG(LogLevel logLevel, const char *format,...)
object * create_archetype_by_object_name(const char *name)
static void local_check_loaded_object(object *op)
archetype * find_archetype(const char *name)
void init(int argc, char **argv)
object * object_insert_in_ob(object *op, object *where)
void object_update_speed(object *op)
object * arch_to_object(archetype *at)
region * get_region_by_map(mapstruct *m)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
const char *const spell_mapping[SPELL_MAPPINGS]
mapstruct * get_empty_map(int sizex, int sizey)
START_TEST(test_randommaps)