52 static int reference_number = 0;
56 for (x = 0; x <
MAP_WIDTH(map) && exit_ob == NULL; x++) {
57 for (y = 0; y <
MAP_HEIGHT(map) && exit_ob == NULL; y++) {
58 for (exit_ob =
GET_MAP_OB(map, x, y); exit_ob != NULL; exit_ob = exit_ob->above)
59 if (exit_ob->type ==
EXIT && exit_ob->msg != NULL)
69 memset(&rp, 0,
sizeof(
RMParms));
95 snprintf(buf,
sizeof(buf),
"%s", cp);
96 while (isdigit(buf[strlen(buf)-1]))
97 buf[strlen(buf)-1] = 0;
100 snprintf(newmap_name,
sizeof(newmap_name),
"/random/%s%04d", cp+1, reference_number++);
105 static void do_run() {
109 int iteration, x, y, map;
113 for (map = 1; map <= 3; map++) {
114 snprintf(path,
sizeof(path),
"/whalingoutpost/underwaterdungeon/level%d", map);
116 fail_unless(worldmap != NULL,
"Can't load %s", path);
121 while (random != NULL) {
122 random = get_random_map(random);
129 for (x = 0; x <
MAP_WIDTH(random); x++) {
133 fail_unless(check->
inv != NULL,
"Horn has empty inventory!");
138 fail_unless(iteration != 0,
"did %d iterations", iteration);
146 static void do_run() {
148 int x, y, found = 0, test = 0;
152 fail_unless(overlay != NULL,
"Couldn't load unique map ../../rsc/bug_1727944_unique");
154 while (found == 0 && test < 10) {
156 fail_unless(map != NULL,
"couldn't load map ../../rsc/bug_1727944");
162 fail_unless(check->
inv != NULL,
"Horn has empty inventory!");
163 fail_unless(check->
inv->
below == NULL,
"Horn has 2 items in inventory!");
164 if (check->
title && strcmp(check->
title,
"of Plenty") == 0) {
227 }
else if ((!strcmp(op->
skill,
"one handed weapons") && op->
body_info[1] != -1)
228 || (!strcmp(op->
skill,
"two handed weapons") && op->
body_info[1] != -2)) {
229 LOG(
llevError,
"weapon %s arm usage does not match skill: %d, %s\n",
250 LOG(
llevDebug,
"Object %s still has last_heal set, not gen_sp_armour\n", op->
name ? op->
name :
"NULL");
353 for (test = 0; test < 50; test++)
356 for (test = 0; test < 50; test++) {
358 fail_unless(overlay != NULL,
"Couldn't load unique map ../../rsc/bug_1727944_unique");
359 fail_unless(
GET_MAP_OB(overlay, 2, 3) != NULL,
"No item on spot 2,3?");
361 for (check =
GET_MAP_OB(overlay, 2, 3)->above; check != NULL; check = check->
above) {
362 fail_unless(check->
type ==
HORN,
"Found a non horn?");
363 fail_unless(check->
inv != NULL,
"Horn without a spell!");
364 fail_unless(check->
inv->
below == NULL,
"Horn with 2 items in inventory.");
374 fail_unless(horn != NULL,
"couldn't find archetype horn.");
376 fail_unless(horn2 != NULL,
"couldn't find archetype horn2.");
378 for (test = 0; test < 100000; test++) {
382 fail_unless(check->
inv != NULL,
"horn without inventory!");
386 int test, level, found = 0;
387 object *the_chest, *check;
390 fail_unless(tlist != NULL,
"couldn't find treasure list uncommon_items");
392 for (test = 0; test < 10; test++) {
393 for (level = 1; level < 120; level++) {
395 fail_unless(map != NULL,
"failed to get empty map");
399 fail_unless(the_chest != NULL,
"failed to get chest");
401 the_chest->
stats.
hp = RANDOM()%100;
405 fail_unless(the_chest != NULL,
"failed to recover chest?");
406 for (check = the_chest->
inv; check; check = check->
below) {
410 fail_unless(check->
inv != NULL,
"horn without inventory");
411 fail_unless(check->
inv->
below == NULL,
"horn with 2 items");
412 fail_unless(check->
randomitems == NULL,
"horn with randomitems set");
418 fail_unless(found > 100,
"didn't find 100 horn but %d??", found);
424 Suite *s = suite_create(
"bug");
425 TCase *tc_core = tcase_create(
"Core");
430 suite_add_tcase(s, tc_core);
431 tcase_add_test(tc_core, test_randommaps);
432 tcase_set_timeout(tc_core, 0);
440 SRunner *sr = srunner_create(s);
442 srunner_set_fork_status(sr, CK_NOFORK);
445 srunner_set_xml(sr, LOGDIR
"/bugs/bugtrack/1727944.xml");
446 srunner_set_log(sr, LOGDIR
"/bugs/bugtrack/1727944.out");
447 srunner_run_all(sr, CK_ENV);
448 nf = srunner_ntests_failed(sr);
450 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
archetype * find_archetype(const char *name)
mapstruct * get_empty_map(int sizex, int sizey)
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout)
object * insert_ob_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
treasurelist * find_treasurelist(const char *name)
mapstruct * ready_map_name(const char *name, int flags)
void free_string(sstring str)
struct treasureliststruct * randomitems
void flag_inv(object *op, int flag)
region * get_region_by_map(mapstruct *m)
object * create_archetype_by_object_name(const char *name)
void set_materialname(object *op, int difficulty, materialtype_t *nmt)
void remove_ob(object *op)
void fix_auto_apply(mapstruct *m)
object * create_archetype(const char *name)
END_TEST Suite * bug_suite(void)
static void local_check_loaded_object(object *op)
int can_merge(object *ob1, object *ob2)
void generate_artifact(object *op, int difficulty)
#define FLAG_IS_A_TEMPLATE
void init(int argc, char **argv)
#define QUERY_FLAG(xyz, p)
object * insert_ob_in_ob(object *op, object *where)
int save_map(mapstruct *m, int flag)
sint8 body_info[NUM_BODY_LOCATIONS]
int snprintf(char *dest, int max, const char *format,...)
START_TEST(test_randommaps)
int set_random_map_variable(RMParms *rp, const char *buf)
const char *const spell_mapping[]
#define MAP_PLAYER_UNIQUE
struct regiondef * region
void delete_map(mapstruct *m)
void update_ob_speed(object *op)
sstring add_string(const char *str)
#define GET_MAP_OB(M, X, Y)
void LOG(LogLevel logLevel, const char *format,...)
void copy_object(object *op2, object *op)
int calc_item_power(const object *op, int flag)
object * arch_to_object(archetype *at)
#define FLAG_CONTENT_ON_GEN
archetype * get_archetype_struct(void)
#define SAVE_MODE_OVERLAY