Christian Georg Becker | eea981a | 2017-03-07 14:19:40 +0100 | [diff] [blame] | 1 | #pragma strong_types,save_types,rtt_checks |
| 2 | #pragma no_clone,no_inherit,no_shadow |
| 3 | #pragma pedantic, range_check |
| 4 | |
| 5 | #include <rooms.h> |
| 6 | #include <files.h> |
| 7 | #include <properties.h> |
| 8 | #include <config.h> |
| 9 | |
| 10 | inherit "/std/room"; |
| 11 | |
| 12 | protected void add_testmud_gexits(); |
| 13 | |
| 14 | protected void create() { |
| 15 | ::create(); |
| 16 | |
| 17 | SetProp(P_INT_LONG, |
| 18 | break_string( |
| 19 | "Du befindest Dich im \"Konstrukt\", einem weissen Nichts eines " |
| 20 | "jungfraeulichen Universums. Dieser Ort wartet darauf, dass Du ihn " |
| 21 | "mit Deiner Phantasie auffuellst. Von hier aus kann man wohl durch " |
| 22 | "blossen Willen andere Orte erreichen, die es in diesem jungen " |
| 23 | "Universum schon gibt.", 78)); |
| 24 | SetProp(P_INT_SHORT, "Im Konstrukt"); |
| 25 | SetProp(P_LIGHT, 1); |
| 26 | |
| 27 | AddDetail(({"konstrukt","nichts"}), |
| 28 | break_string("Es ist weiss - und sonst Nichts.", 78)); |
| 29 | AddDetail("universum", |
| 30 | break_string("Es liegt dir zu Fuessen.", 78)); |
| 31 | AddDetail(({"fuss","fuesse"}), |
| 32 | break_string("Deine Fuesse.", 78)); |
| 33 | AddDetail("phantasie", |
| 34 | break_string("Sie schlummert in dir. Es ist an dir, ihr Gestalt " |
| 35 | "zu geben.", 78)); |
| 36 | |
| 37 | AddExit("bsp","/doc/beispiele/misc/bspraum1"); |
| 38 | AddExit("ssp","/doc/beispiele/ssp/l1/m3x1"); |
| 39 | AddExit("zauberwald","/doc/beispiele/zauberwald/room/eingang"); |
| 40 | AddExit("gilde","/gilden/abenteurer"); |
| 41 | |
| 42 | #if defined(__TESTMUD__) || MUDHOST!=__HOST_NAME__ |
| 43 | ({"/doc/beispiele/misc/bspraum1", |
| 44 | "/doc/beispiele/ssp/l1/m3x1", |
| 45 | "/doc/beispiele/zauberwald/room/eingang"})->AddExit("konstrukt", |
| 46 | load_name(this_object())); |
| 47 | call_out(#'add_testmud_gexits, 1); |
| 48 | #endif |
| 49 | } |
| 50 | |
| 51 | protected string get_vcomp_possibility(mapping gdirectory) { |
| 52 | foreach(string path, int tp: gdirectory) { |
| 53 | if(tp>20) { |
| 54 | string head = read_file(path); |
| 55 | if(head && strstr(head, "compile_object")>=0) { |
| 56 | return path; |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | protected void get_dirs_and_files(mapping gdirs, mapping gfiles) { |
| 64 | mapping gdirectory = |
| 65 | mkmapping(get_dir("/gilden/", GETDIR_PATH|GETDIR_UNSORTED), |
| 66 | get_dir("/gilden/", GETDIR_SIZES)); |
| 67 | m_delete(gdirectory, "/gilden/access_rights.c"); |
| 68 | |
| 69 | gdirs = filter(gdirectory, function int(string path, int tp) { |
| 70 | if(tp == FSIZE_DIR) |
| 71 | return 1; |
| 72 | return 0; |
| 73 | }); |
| 74 | gfiles = filter(gdirectory, function int(string path, int tp) { |
| 75 | if(tp > 0) |
| 76 | return 1; |
| 77 | return 0; |
| 78 | }); |
| 79 | } |
| 80 | |
| 81 | protected void try_add_gexit(string realpath, string *added_exists) { |
| 82 | object ob; |
| 83 | if(member(added_exists, realpath)<0 && |
| 84 | !catch(ob=load_object(realpath); nolog) && ob && |
| 85 | member(inherit_list(ob), "/std/gilden_room.c")>=0) { |
| 86 | AddExit(explode(realpath, "/")[<1][0..<3], realpath); |
| 87 | ob->AddExit("konstrukt", load_name(this_object())); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | protected void add_testmud_gexits() { |
| 92 | mapping gdirs, gfiles; |
| 93 | get_dirs_and_files(&gdirs, &gfiles); |
| 94 | |
| 95 | string vcomp = get_vcomp_possibility(gfiles); |
| 96 | m_delete(gfiles, vcomp); |
| 97 | |
| 98 | string *added_exists = allocate(0); |
| 99 | foreach(string path, int tp: gfiles) |
| 100 | try_add_gexit(path, &added_exists); |
| 101 | |
| 102 | if(vcomp) |
| 103 | foreach(string path, int tp: gdirs) |
| 104 | if(strstr(path, "files.")>0) { |
| 105 | string realpath = implode(explode(path, "files."), "")+".c"; |
| 106 | try_add_gexit(realpath, &added_exists); |
| 107 | } |
| 108 | } |