#include <defines.h>#include <properties.h>#include <v_compiler.h>#include "../files.h"#include <config.h>
gehe zum Quellcode dieser Datei
Makrodefinitionen | |
| #define | HEADERFILE "/p/service/padreic/kraeuter/plant.h" |
| #define | KATEGORYS |
Funktionen | |
| void | update_header_file () |
| int | _createfile (string filename) |
| void | create () |
| mixed | compile_object (string file) |
| string | Validate (string file) |
| static nomask private string | get_cloner () |
| varargs | CustomizeObject (string file) |
| int | NoParaObjects () |
Variablen | |
| inherit std virtual | v_compiler |
| inherit std thing | language |
| inherit std thing | description |
| private mapping | map_ldfied |
| private mapping | validfiles |
| private nosave object | simul_efun |
| #define HEADERFILE "/p/service/padreic/kraeuter/plant.h" |
Definiert in Zeile 12 der Datei virtual_compiler.c.
| #define KATEGORYS |
({ "klee", "rebe", "hahnenfuss", "rettich", "kraut", "wurz",\
"moos", "enzian", "rautenwicke", "pilz", "nelke",\
"lichtnelke"})
Definiert in Zeile 52 der Datei virtual_compiler.c.
| int _createfile | ( | string | filename | ) |
Definiert in Zeile 56 der Datei virtual_compiler.c.
00057 { 00058 int i; 00059 mixed *arr; 00060 string str, short, long, gender, *name, roomdetail; 00061 string *ids; 00062 string plantfile; 00063 00064 if (object_name(previous_object())!=PLANTMASTER) { 00065 write("Illegal usage of _createfile()!\n"); 00066 return 1; 00067 } 00068 if (!pointerp(arr=map_ldfied[filename])) { 00069 write("Unknown Plant '"+filename+"'.\n"); 00070 return 1; 00071 } 00072 if (file_size(PLANTDIR+filename+".c")>=0) { 00073 write("error: file "+PLANTDIR+filename+".c allready exists.\n"); 00074 return 1; 00075 } 00076 00077 // Kurzbeschreibung erzeugen 00078 SetProp(P_NAME, arr[0][INGREDIENT_NAME]); 00079 SetProp(P_NAME_ADJ, arr[0][INGREDIENT_ADJ]); 00080 SetProp(P_GENDER, arr[0][INGREDIENT_GENDER]); 00081 if (arr[0][INGREDIENT_DEMON]==RAW) { 00082 SetProp(P_ARTICLE, 0); 00083 short=Name(WER); 00084 SetProp(P_ARTICLE, 1); 00085 } 00086 else short=Name(WER,arr[0][INGREDIENT_DEMON]); 00087 ids = ({ lowerstring(arr[0][INGREDIENT_NAME]) }); 00088 // bei zusammengesetzten Namen, auch den hauptnamen akzeptieren 00089 str=lowerstring(arr[0][INGREDIENT_NAME]); 00090 name=explode(str, "-"); 00091 if (sizeof(name)>1) ids += ({ name[<1] }); 00092 name=explode(str, " "); 00093 if (sizeof(name)>1) ids += ({ name[<1] }); 00094 for (i=sizeof(KATEGORYS)-1; i>=0; i--) { 00095 if (strstr(str, KATEGORYS[i], 0)==-1) continue; 00096 ids += ({ KATEGORYS[i] }); 00097 break; 00098 } 00099 switch(arr[0][INGREDIENT_GENDER]) { 00100 case MALE: gender="MALE"; break; 00101 case FEMALE: gender="FEMALE"; break; 00102 case NEUTER: gender="NEUTER"; break; 00103 default: gender=arr[0][INGREDIENT_GENDER]; 00104 } 00105 long=" \""+implode(old_explode(arr[0][INGREDIENT_LONG], "\n"), "\\n\"\n +\"")+"\\n\""; 00106 roomdetail=" \""+implode(old_explode(arr[0][INGREDIENT_ROOMDETAIL], "\n"), "\\n\"\n +\"")+"\\n\""; 00107 plantfile= 00108 "// (c) 2001 by Padreic (Padreic@mg.mud.de)\n\n" 00109 +"#include <properties.h>\n" 00110 +"#include \"../files.h\"\n" 00111 +"#include \"/p/service/padreic/kraeuter/plant.h\"\n\n" 00112 +"inherit PLANT(\"plant\");\n\n" 00113 +"void create()\n" 00114 +"{\n" 00115 +" ::create("+upperstring(filename)+");\n" 00116 +" SetProp(P_NAME, \""+arr[0][INGREDIENT_NAME]+"\");\n" 00117 +" SetProp(P_NAME_ADJ, \""+(arr[0][INGREDIENT_ADJ]||"")+"\");\n" 00118 +" SetProp(P_GENDER, "+gender+");\n" 00119 +" SetProp(P_LONG, \n" 00120 +long+");\n" 00121 +" SetProp(PLANT_ROOMDETAIL, \n" 00122 +roomdetail+");\n" 00123 +" SetProp(P_SHORT, \""+short+"\");\n"; 00124 plantfile+=" AddId(({"; 00125 for (i=sizeof(ids)-1; i>=0; i--) 00126 plantfile+=" \""+ids[i]+"\","; 00127 plantfile[<1]=' '; 00128 plantfile+="}));\n"; 00129 // Adjective vorher deklinieren 00130 if (stringp(short=arr[0][INGREDIENT_ADJ])) { 00131 short=DeclAdj(lowerstring(short), WEN, 0)[0..<2]; 00132 plantfile+=" AddAdjective(\""+short+"\");\n"; 00133 } 00134 plantfile+="}\n"; 00135 write_file(PLANTDIR+filename+".c", plantfile); 00136 write(PLANTDIR+filename+".c created.\n"); 00137 return 1; 00138 }
| mixed compile_object | ( | string | file | ) |
Definiert in Zeile 158 der Datei virtual_compiler.c.
00159 { 00160 string str; 00161 // es gibt einige files auch einzeln... 00162 if (file_size(SECURE(str=explode(file, "/")[<1]+".c"))>0) 00163 return clone_object(SECURE(str)); 00164 return ::compile_object(file); 00165 }
| void create | ( | ) |
Definiert in Zeile 140 der Datei virtual_compiler.c.
00141 { 00142 if (clonep(this_object())) { 00143 destruct(this_object()); 00144 raise_error("Don't clone VirtualCompiler!\n"); 00145 } 00146 seteuid(getuid()); 00147 // Daten update durchfuehrn 00148 if (!restore_object(object_name())) 00149 raise_error("Data not available!\n"); 00150 if (!restore_object(KRAEUTERVCSAVEFILE)) map_ldfied=([]); 00151 v_compiler::create(); 00152 description::create(); 00153 00154 SetProp(P_COMPILER_PATH, "/p/service/padreic/kraeuter"); 00155 SetProp(P_STD_OBJECT, "/p/service/padreic/kraeuter/plant.c"); 00156 }
| varargs CustomizeObject | ( | string | file | ) |
Definiert in Zeile 215 der Datei virtual_compiler.c.
00216 { 00217 int i, legal; 00218 mixed arr; 00219 string str, *name; 00220 closure sp; 00221 object cloner; 00222 00223 if (stringp(file)) 00224 file=Validate(file); 00225 else file=::CustomizeObject(); 00226 if (!file) return 0; 00227 if (previous_object()->QueryPlantId()) return 0; // bereits initialisiert 00228 sp=symbol_function("SetProp", previous_object()); 00229 if (pointerp(arr=map_ldfied[file])) { 00230 // Blueprint oder legal cloner 00231 cloner = get_cloner(); 00232 legal=(member(arr[1], get_cloner())>=0) || (object_name(cloner)==PLANTMASTER); 00233 if (BLUE_NAME(previous_object())==STDPLANT || 00234 !clonep(previous_object()) || legal) 00235 { 00236 if ((arr[0][INGREDIENT_NAME]=="Klee") || 00237 (arr[0][INGREDIENT_NAME][<4..]=="klee")) { 00238 funcall(sp, P_NAME, ({ arr[0][INGREDIENT_NAME], 00239 arr[0][INGREDIENT_NAME]+"s", 00240 arr[0][INGREDIENT_NAME], 00241 arr[0][INGREDIENT_NAME]})); 00242 } 00243 else funcall(sp, P_NAME, arr[0][INGREDIENT_NAME]); 00244 funcall(sp, P_NAME_ADJ, arr[0][INGREDIENT_ADJ]); 00245 funcall(sp, P_GENDER, arr[0][INGREDIENT_GENDER]); 00246 funcall(sp, P_LONG, arr[0][INGREDIENT_LONG]); 00247 funcall(sp, PLANT_ROOMDETAIL, arr[0][INGREDIENT_ROOMDETAIL]); 00248 if (arr[0][INGREDIENT_DEMON]==RAW) { 00249 funcall(sp, P_ARTICLE, 0); 00250 funcall(sp, P_SHORT, previous_object()->Name(WER)); 00251 funcall(sp, P_ARTICLE, 1); 00252 } 00253 else funcall(sp, P_SHORT, previous_object()->Name(WER,arr[0][INGREDIENT_DEMON])); 00254 previous_object()->AddId(lowerstring(arr[0][INGREDIENT_NAME])); 00255 // bei zusammengesetzten Namen, auch den hauptnamen akzeptieren 00256 str=lowerstring(arr[0][INGREDIENT_NAME]); 00257 name=explode(str, "-"); 00258 if (sizeof(name)>1) previous_object()->AddId(name[<1]); 00259 name=explode(str, " "); 00260 if (sizeof(name)>1) previous_object()->AddId(name[<1]); 00261 for (i=sizeof(KATEGORYS)-1; i>=0; i--) { 00262 if (strstr(str, KATEGORYS[i], 0)==-1) continue; 00263 previous_object()->AddId(KATEGORYS[i]); 00264 break; 00265 } 00266 // Adjective vorher deklinieren 00267 if (stringp(str=arr[0][INGREDIENT_ADJ])) { 00268 str=DeclAdj(lowerstring(str), WEN, 0); 00269 previous_object()->AddAdjective(str); 00270 } 00271 previous_object()->SetPlantId(legal ? arr[0][INGREDIENT_ID] : -1); 00272 return file; 00273 } 00274 } 00275 funcall(sp, P_NAME, "Kraut"); 00276 funcall(sp, P_GENDER, NEUTER); 00277 funcall(sp, P_SHORT, "Ein Testkraut ("+capitalize(file)+")"); 00278 funcall(sp, P_LONG, "Ein nicht naeher spezifiziertes Testkraut.\n"); 00279 funcall(sp, PLANT_ROOMDETAIL, "Ein nicht naeher spezifiziertes Testkraut ("+capitalize(file)+").\n"); 00280 previous_object()->AddId("kraut"); 00281 previous_object()->SetPlantId(-1); 00282 return file; 00283 }
| static nomask private string get_cloner | ( | ) | [static] |
Definiert in Zeile 180 der Datei virtual_compiler.c.
00181 { 00182 int i; 00183 object po; 00184 /* 00185 if (!master) { 00186 master=find_object("/secure/master.c"); 00187 if (!master) raise_error("inkonsistent system!\n"); 00188 } 00189 */ 00190 // Es kann nicht passieren, dass es keine simul_efun oder master gibt, denn 00191 // dann wird das Mud runtergefahren. Ausserdem sollte man die Pfade nicht 00192 // hart-kodieren. 00193 /* 00194 if (!simul_efun) { 00195 if (!(simul_efun=find_object("/secure/simul_efun"))) 00196 simul_efun=find_object("/secure/spare_simul_efun.c"); 00197 if (!simul_efun) raise_error("inkonsistent system!\n"); 00198 } 00199 */ 00200 if (!simul_efun) { 00201 if (!(simul_efun=find_object(SIMUL_EFUN_FILE))) 00202 simul_efun=find_object(SPARE_SIMUL_EFUN_FILE); 00203 } 00204 // wenn sie jetzt nicht existiert - auch gut, dann gibt es halt keine 00205 // sefuns. 00206 00207 for (i=0; po=previous_object(i); i++) { 00208 if (po==master() || po==simul_efun || po==ME || po==previous_object()) 00209 continue; 00210 else return BLUE_NAME(po); 00211 } 00212 return 0; 00213 }
| int NoParaObjects | ( | ) |
Definiert in Zeile 286 der Datei virtual_compiler.c.
Wird benutzt von QueryValidObject().

| void update_header_file | ( | ) |
Definiert in Zeile 21 der Datei virtual_compiler.c.
Benutzt i, keys, KRAEUTERVCSAVEFILE, map_ldfied, restore_object(), save_object() und validfiles.
00022 { 00023 int i, si; 00024 string *keys; 00025 mapping tmp; 00026 00027 // Daten update durchfuehrn 00028 if (!restore_object(KRAEUTERVCSAVEFILE)) 00029 raise_error("Data not available!\n"); 00030 00031 keys=m_indices(map_ldfied); 00032 si=sizeof(keys); 00033 validfiles=([]); 00034 for (i=si-1; i>=0; i--) validfiles+=([ keys[i] ]); 00035 00036 // validfiles speichern... 00037 tmp=map_ldfied; map_ldfied=([]); save_object(object_name()); map_ldfied=tmp; 00038 00039 if (si<=0) raise_error("Data not available!\n"); 00040 keys=sort_array(keys, #'<); 00041 rm(HEADERFILE); 00042 write_file(HEADERFILE, 00043 "// Automatisch generiertes File, nicht von Hand editieren!\n" 00044 +"// Erzeugendes File: "+object_name()+"\n\n" 00045 +"#define PLANTCOUNT "+to_string(si)+"\n\n" 00046 +"#define PLANT(x) \"/p/service/padreic/kraeuter/\"+x\n\n" 00047 ); 00048 for (i=si-1; i>=0; i--) 00049 write_file(HEADERFILE, sprintf("#define %-30s PLANT(\"%s\")\n", upperstring(keys[i]), keys[i])); 00050 }

| string Validate | ( | string | file | ) |
Definiert in Zeile 167 der Datei virtual_compiler.c.
| inherit std thing description |
Definiert in Zeile 10 der Datei virtual_compiler.c.
Wird benutzt von insert_detail() und show_all_details().
Definiert in Zeile 9 der Datei virtual_compiler.c.
| private mapping map_ldfied |
Definiert in Zeile 17 der Datei virtual_compiler.c.
Wird benutzt von InsertSensitiveObject(), RegisterTarget() und update_header_file().
| private nosave object simul_efun |
Definiert in Zeile 176 der Datei virtual_compiler.c.
| inherit std virtual v_compiler |
Definiert in Zeile 8 der Datei virtual_compiler.c.
| private mapping validfiles |
Definiert in Zeile 18 der Datei virtual_compiler.c.
Wird benutzt von update_header_file().
1.6.3