MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | // KNETE.C -- CommandLine Frontend to the Lisp2Closure compiler |
| 2 | // (c) 1994 by Hate@MorgenGrauen, TUBmud, NightFall |
| 3 | // -- |
| 4 | // Copy, change and distribute this bit of software as much as you like, |
| 5 | // but keep the name of the original author in the header. |
| 6 | |
| 7 | #include "tweak.h" |
| 8 | |
| 9 | static inherit HOME("lisp"); |
| 10 | |
| 11 | #ifdef ALATIA |
| 12 | # define TUBMUD |
| 13 | #endif |
| 14 | // TUBMUD is a COMPAT mode game! (well sort of, its a NATIVE/COMPAT mixture) |
| 15 | // the following defines should be the only ones to change |
| 16 | // define ENGLISH if you don't want german messages ;) |
| 17 | #if (defined(TUBMUD) || defined(TAPPMUD) || defined(UNItopia) || \ |
| 18 | defined(ADAMANT)) |
| 19 | # ifdef ADAMANT |
| 20 | # include <config.h> |
| 21 | inherit "/lib/obj"; |
| 22 | # define WIZLOCAL "/wiz/" |
| 23 | # define ID(x) set_name(x) |
| 24 | # define SHORT(x) set_short(x) |
| 25 | # define LONG(x) set_long(x) |
| 26 | # define ISWIZARD(pl) (LEVELMASTER->is_wizard(pl->query_real_name())) |
| 27 | # endif |
| 28 | # ifdef TUBMUD |
| 29 | # include <kernel.h> |
| 30 | # include <wizlevels.h> |
| 31 | inherit ACCESS; |
| 32 | inherit "/complex/item"; |
| 33 | inherit "/basic/autoload"; |
| 34 | # define WIZLOCAL "/players/" |
| 35 | # define ID(x) add_id(x) |
| 36 | # define ISWIZARD(pl) (pl->query_level() >= WL_WIZARD) |
| 37 | # endif |
| 38 | # ifdef TAPPMUD |
| 39 | # include <levels.h> |
| 40 | inherit "/obj/thing"; |
| 41 | # define WIZLOCAL "/w/" |
| 42 | # define ID(x) set_alias(x) |
| 43 | # define ISWIZARD(pl) (pl->query_level() >= LVL_WIZARD) |
| 44 | # endif |
| 45 | # define ENGLISH |
| 46 | # ifdef UNItopia |
| 47 | # undef ENGLISH |
| 48 | # ifdef FinalFrontier |
| 49 | # include <level.h> |
| 50 | # else |
| 51 | # include <levels.h> |
| 52 | # endif |
| 53 | inherit "/i/item"; |
| 54 | inherit "/i/install"; |
| 55 | # define WIZLOCAL "/w/" |
| 56 | # define ID(x) add_id(x) |
| 57 | # define ISWIZARD(pl) wizp(pl) |
| 58 | # endif |
| 59 | # define WIZHOME (WIZLOCAL+this_player()->query_real_name()) |
| 60 | # define LONG(x) set_long(x) |
| 61 | # define SHORT(x) set_short(x) |
| 62 | #else |
| 63 | inherit "/std/thing"; |
| 64 | # ifdef NIGHTFALL |
| 65 | # define ENGLISH |
| 66 | # endif |
| 67 | # include <properties.h> |
| 68 | # include <wizlevels.h> |
| 69 | # define WIZHOME ("/players/"+getuid(this_object())) |
| 70 | # define ID(x) AddId(x); SetProp(P_NAME, x) |
| 71 | # define LONG(x) SetProp(P_LONG, x) |
| 72 | # define SHORT(x) SetProp(P_SHORT, x); |
| 73 | # define ISWIZARD(pl) IS_WIZARD(pl) |
| 74 | #endif |
| 75 | |
| 76 | nomask void create() |
| 77 | { |
| 78 | if(sizeof(old_explode(object_name(this_object()), "#")) == 1) return; |
| 79 | if(!interactive(this_player())) destruct(this_object()); |
| 80 | #ifndef MORGENGRAUEN |
| 81 | if((this_player() != find_player("hate") && |
| 82 | interactive(find_player("hate"))) && |
| 83 | old_explode(object_name(this_object()), "#")[0] == HOME("knete")) |
| 84 | { |
| 85 | #ifdef TUBMUD |
| 86 | if(check_privilege("hate")) set_privilege("hate"); |
| 87 | else set_privilege(0); |
| 88 | #else |
| 89 | printf("*ERROR: do not clone this file!\n" |
| 90 | +" create a file with the following line in you home:\n" |
| 91 | +"inherit \""+HOME("knete")+"\";\n"); |
| 92 | destruct(this_object()); |
| 93 | return; |
| 94 | #endif |
| 95 | } |
| 96 | #endif |
| 97 | #if (defined(TUBMUD) || defined(UNItopia)) |
| 98 | item::create(); |
| 99 | #elif (defined(ADAMANT)) |
| 100 | obj::create(); |
| 101 | #else |
| 102 | thing::create(); |
| 103 | #endif |
| 104 | #ifdef ENGLISH |
| 105 | ID("dough"); |
| 106 | ID("lisp"); |
| 107 | SHORT("A piece of dough\n"); |
| 108 | LONG("This piece of dough can be formed to your own convenience.\n"); |
| 109 | #else |
| 110 | # ifdef UNItopia |
| 111 | set_name("Knete"); |
| 112 | # endif |
| 113 | ID("knete"); |
| 114 | ID("lisp"); |
| 115 | SHORT("Ein Stueck Knete"); |
| 116 | LONG( |
| 117 | "Dieses Stueck Knete kann man sehr schoen an seinen persoenlichen Geschmack\n" |
| 118 | +"anpassen.\n"); |
| 119 | this_object()->SetProp("autoloadobj",1); |
| 120 | this_object()->SetProp("autoload",1); |
| 121 | #endif |
| 122 | lisp::create(); |
| 123 | } |
| 124 | |
| 125 | varargs nomask void init(int x) |
| 126 | { |
| 127 | lisp::init(x); |
| 128 | #if (defined(TUBMUD) || defined(UNItopia)) |
| 129 | # ifndef TUBMUD |
| 130 | item::init(); |
| 131 | # endif |
| 132 | #elif (defined(ADAMANT)) |
| 133 | obj::init(); |
| 134 | #else |
| 135 | thing::init(); |
| 136 | #endif |
| 137 | add_action("cmdline", "", 1); |
| 138 | } |
| 139 | |
| 140 | #ifdef TAPPMUD |
| 141 | query_auto_load() { return ({__FILE__}); } |
| 142 | drop() { return 1; } |
| 143 | #endif |
| 144 | #if ((defined(TUBMUD)) || (defined(ADAMANT))) |
| 145 | drop() { return 1; } |
| 146 | #endif |
| 147 | |
| 148 | nomask string load(string file) |
| 149 | { |
| 150 | if(previous_object() != this_object()) return "* Privilege violation\n"; |
| 151 | return lisp(read_file(file)); |
| 152 | } |
| 153 | |
| 154 | nomask int cmdline(string str) |
| 155 | { |
| 156 | int cost; |
| 157 | cost = get_eval_cost(); |
| 158 | if(this_player() != this_interactive()) return 0; |
| 159 | |
| 160 | #ifndef MORGENGRAUEN |
| 161 | # ifndef TUBMUD |
| 162 | if(this_player() && interactive(this_player()) && |
| 163 | ((this_player() != find_player("hate")) || |
| 164 | (this_player() != find_player("etah")))) |
| 165 | # endif |
| 166 | #else |
| 167 | if(this_player() && interactive(this_player())) |
| 168 | #endif |
| 169 | { |
| 170 | mixed result; |
| 171 | if(!ISWIZARD(this_player())) return 0; |
| 172 | #ifdef TAPPMUD |
| 173 | notify_fail(lambda(({}), ({#'lisp/*'*/, |
| 174 | query_verb()+(str?(" "+str):""), 1}))); |
| 175 | #else |
| 176 | # ifdef MORGENGRAUEN |
| 177 | str = this_player()->_unparsed_args(); |
| 178 | # endif |
| 179 | result = lisp(query_verb()+(str?(" "+str):""), 1); |
| 180 | if(result != -1 && cost >= 990000) { |
| 181 | if(stringp(result)) |
| 182 | notify_fail(result); |
| 183 | else |
| 184 | if(result) notify_fail(sprintf("%O\n", result)); |
| 185 | else return 1; |
| 186 | return 0; |
| 187 | } |
| 188 | #endif |
| 189 | } |
| 190 | } |