MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | /* |
| 2 | Objekt zum Eintragen von Raeumen die Zaubertraenke enthalten beim |
| 3 | potionmaster. |
| 4 | */ |
| 5 | |
| 6 | #include <wizlevels.h> |
| 7 | #include <properties.h> |
| 8 | #include <language.h> |
| 9 | |
| 10 | inherit "std/thing"; |
| 11 | |
| 12 | int dump(); |
| 13 | |
| 14 | int secure() |
| 15 | { |
| 16 | if (!previous_object()) return 0; |
| 17 | if (geteuid(previous_object())==ROOTID) return 1; |
| 18 | if (geteuid(previous_object()) != geteuid(this_interactive())) return 0; |
| 19 | if (this_interactive() != this_player()) return 0; |
| 20 | if (!ARCH_SECURITY) return 0; |
| 21 | return 1; |
| 22 | } |
| 23 | |
| 24 | void create() |
| 25 | { |
| 26 | if (!clonep(this_object())) return; |
| 27 | ::create(); |
| 28 | SetProp(P_SHORT, "Potion-Tool"); |
| 29 | SetProp(P_LONG, |
| 30 | "Ein Tool zum Eintragen von Raumen in den Potionmaster.\n"+ |
| 31 | "Folgende Befehle gibt es:\n"+ |
| 32 | "ptadd <liste> Addiert den ZT im Raum in Liste <liste>\n"+ |
| 33 | " und aktiviert ihn gleichzeitig.\n"+ |
| 34 | "ptset <liste> Aktiviert den ZT im Raum und setzt ihn in\n"+ |
| 35 | " die Liste <liste>.\n"+ |
| 36 | "ptchange <nummer> Ersetzt den ZT <nummer> durch den ZT im Raum.\n"+ |
| 37 | "ptact Aktiviert einen deaktivierten ZT in seiner\n"+ |
| 38 | " bisherigen Liste.\n"+ |
| 39 | "ptdeact Deaktiviert den ZT im Raum aus der ZTListe\n"+ |
| 40 | " und verschiebt ihn nach 'deaktivierte ZTs'.\n"+ |
| 41 | "ptinfo [para] kein para: Zeigt Infos ueber den ZT im aktu-\n"+ |
| 42 | " ellen Raum.\n"+ |
| 43 | " int para: Zeigt Infos zum ZT para an.\n"+ |
| 44 | " string para: Zeigt ZT-Infos des Spielers para.\n"+ |
| 45 | "ptdump Erzeugt ein Dump der aktuellen ZTListe und\n"+ |
| 46 | " speichert diesen ab.\n\n"); |
| 47 | SetProp(P_NAME, "PTool"); |
| 48 | SetProp(P_GENDER, NEUTER); |
| 49 | AddId(({"tool", "ptool"})); |
| 50 | SetProp(P_NODROP, 1); |
| 51 | SetProp(P_AUTOLOADOBJ, 1); |
| 52 | AddCmd("ptadd", "add"); |
| 53 | AddCmd("ptset", "setlist"); |
| 54 | AddCmd("ptchange", "changepath"); |
| 55 | AddCmd("ptact", "activate"); |
| 56 | AddCmd("ptdeact", "deactivate"); |
| 57 | AddCmd("ptinfo", "info"); |
| 58 | AddCmd("ptdump", "dump"); |
| 59 | } |
| 60 | |
| 61 | int add(string number) |
| 62 | { |
| 63 | int nr, next, active; |
| 64 | string room; |
| 65 | if (!secure()) |
| 66 | { printf("Fehler: -1\n"); return -1; } |
| 67 | if (!query_once_interactive(environment())) |
| 68 | { printf("Fehler: -2\n"); return -2; } |
| 69 | if (!number) |
| 70 | { printf("Fehler: -3\n"); return -3; } |
| 71 | sscanf(number, "%d", nr); |
| 72 | if (!intp(nr)) |
| 73 | { printf("Fehler: -4\n"); return -4; } |
| 74 | room = object_name(environment(environment(this_object()))); |
| 75 | next = "/secure/potionmaster"->AddPotionRoom(room,nr); |
| 76 | if (next>0) |
| 77 | printf("Raum in Gesamtliste eingetragen, Nummer: %d\n", next-1); |
| 78 | else |
| 79 | { |
| 80 | printf("Raum konnte nicht eingetragen werden, Ergebnis: %d\n", next); |
| 81 | return 1; |
| 82 | } |
| 83 | // Nicht mehr noetig, Arathorn, 2013-Mai-30 |
| 84 | //active = "/secure/potionmaster"->SetListNr(room, nr); |
| 85 | if (active>=0) |
| 86 | { |
| 87 | printf("Raum aktiviert in Liste %d\n", nr); |
| 88 | dump(); |
| 89 | } |
| 90 | else |
| 91 | printf("Fehler beim Aktivieren, Ergebnis: %d\n", active); |
| 92 | return 1; |
| 93 | } |
| 94 | |
| 95 | int changepath(string number) |
| 96 | { |
| 97 | int nr,neu; |
| 98 | string room; |
| 99 | mixed roomold; |
| 100 | if (!secure()) |
| 101 | { printf("Fehler: -1\n"); return -1; } |
| 102 | if (!query_once_interactive(environment())) |
| 103 | { printf("Fehler: -2\n"); return -2; } |
| 104 | if (!number) |
| 105 | { printf("Fehler: -3\n"); return -3; } |
| 106 | sscanf(number, "%d", nr); |
| 107 | if (!intp(nr)) |
| 108 | { printf("Fehler: -4\n"); return -4; } |
| 109 | room = object_name(environment(environment(this_object()))); |
| 110 | roomold = "/secure/potionmaster"->GetFilenameByNumber(nr); |
| 111 | if (roomold==-1) |
| 112 | { printf("Fehler: -5\n"); return -5; } |
| 113 | neu = "/secure/potionmaster"->ChangeRoomPath(roomold,room); |
| 114 | if (neu>0) |
| 115 | { |
| 116 | printf("ZT %d durch aktuellen Raum ersetzt.\n", neu); |
| 117 | dump(); |
| 118 | } |
| 119 | else |
| 120 | printf("ZT %d konnte nicht ersetzt werden, Ergebnis: %d\n", nr,neu); |
| 121 | return 1; |
| 122 | } |
| 123 | |
| 124 | int setlist(string number) |
| 125 | { |
| 126 | int nr, next, active; |
| 127 | string room; |
| 128 | if (!secure()) |
| 129 | { printf("Fehler: -1\n"); return -1; } |
| 130 | if (!query_once_interactive(environment())) |
| 131 | { printf("Fehler: -2\n"); return -2; } |
| 132 | if (!number) |
| 133 | { printf("Fehler: -3\n"); return -3; } |
| 134 | sscanf(number, "%d", nr); |
| 135 | if (!intp(nr) || nr<0 || nr>7) |
| 136 | { printf("Fehler: -4\n"); return -4; } |
| 137 | room = object_name(environment(environment(this_object()))); |
| 138 | active = "/secure/potionmaster"->SetListNr(room, nr); |
| 139 | if (active>=0) |
| 140 | { |
| 141 | printf("Raum aktiviert in Liste %d\n", nr); |
| 142 | dump(); |
| 143 | } |
| 144 | else |
| 145 | printf("Fehler beim Aktivieren, Ergebnis: %d\n", active); |
| 146 | return 1; |
| 147 | } |
| 148 | |
| 149 | int activate() |
| 150 | { |
| 151 | int nr, active; |
| 152 | string room; |
| 153 | |
| 154 | if (!secure()) |
| 155 | { printf("Fehler: -1\n"); return -1; } |
| 156 | if (!query_once_interactive(environment())) |
| 157 | { printf("Fehler: -2\n"); return -2; } |
| 158 | room = object_name(environment(environment(this_object()))); |
| 159 | active = "/secure/potionmaster"->ActivateRoom(room); |
| 160 | if (active>=0) |
| 161 | { |
| 162 | printf("Raum aktiviert in Liste %d\n", active); |
| 163 | dump(); |
| 164 | } |
| 165 | else |
| 166 | printf("Fehler beim Aktivieren, Ergebnis: %d\n", active); |
| 167 | return 1; |
| 168 | } |
| 169 | |
| 170 | int deactivate() |
| 171 | { |
| 172 | int deactive; |
| 173 | string room; |
| 174 | |
| 175 | if (!secure()) |
| 176 | { printf("Fehler: -1\n"); return -1; } |
| 177 | if (!query_once_interactive(environment())) |
| 178 | { printf("Fehler: -2\n"); return -2; } |
| 179 | room = object_name(environment(environment(this_object()))); |
| 180 | deactive = "/secure/potionmaster"->DeactivateRoom(room); |
| 181 | if (deactive>=0) |
| 182 | { |
| 183 | printf("Raum deaktiviert in Liste %d\n",deactive); |
| 184 | dump(); |
| 185 | } |
| 186 | else |
| 187 | printf("Fehler beim Deaktivieren, Ergebnis: %d\n", deactive); |
| 188 | return 1; |
| 189 | } |
| 190 | |
| 191 | int info(string para) |
| 192 | { |
| 193 | int info,nr; |
| 194 | string s; |
| 195 | object room,o; |
| 196 | mixed m,*potions; |
| 197 | if (!secure()) |
| 198 | { printf("Fehler: -1\n"); return -1; } |
| 199 | if (!query_once_interactive(environment())) |
| 200 | { printf("Fehler: -2\n"); return -2; } |
| 201 | if (!para || para=="") |
| 202 | { |
| 203 | room = environment(environment(this_object())); |
| 204 | info = "/secure/potionmaster"->HasPotion(room); |
| 205 | if (info>=0) |
| 206 | { |
| 207 | printf("Raum hat ZT mit Nr: %d\n\n",info); |
| 208 | nr = "/secure/potionmaster"->GetListByNumber(info); |
| 209 | if (nr>=0) |
| 210 | printf("ZT aktiv in Liste: %d\n\n",nr); |
| 211 | else |
| 212 | { |
| 213 | nr = "/secure/potionmaster"->GetInactListByNumber(info); |
| 214 | if (nr>=0) |
| 215 | printf("ZT INaktiv in Liste: %d\n\n",nr); |
| 216 | else |
| 217 | printf("ZT INaktiv\n\n"); |
| 218 | } |
| 219 | if (info>=0 && s=read_file("/secure/ARCH/ZT/"+info+".zt")) |
| 220 | { |
| 221 | write("Tip:\n"+s); |
| 222 | } |
| 223 | } |
| 224 | else |
| 225 | printf("Raum hat keinen ZT eingetragen.\n"); |
| 226 | } |
| 227 | else |
| 228 | if (sscanf(para,"%d",info)==1) |
| 229 | { |
| 230 | printf("ZT mit Nummer: %d\n\n",info); |
| 231 | m = "/secure/potionmaster"->GetFilenameByNumber(info); |
| 232 | if (m!=-1) |
| 233 | { |
| 234 | write("Filename: "+m+"\n\n"); |
| 235 | nr = "/secure/potionmaster"->GetListByNumber(info); |
| 236 | if (nr>=0) |
| 237 | printf("ZT aktiv in Liste: %d\n\n",nr); |
| 238 | else |
| 239 | { |
| 240 | nr = "/secure/potionmaster"->GetInactListByNumber(info); |
| 241 | if (nr>=0) |
| 242 | printf("ZT INaktiv in Liste: %d\n\n",nr); |
| 243 | else |
| 244 | printf("ZT INaktiv\n\n"); |
| 245 | } |
| 246 | if (info>=0 && s=read_file("/secure/ARCH/ZT/"+info+".zt")) |
| 247 | { |
| 248 | write("Tip:\n"+s); |
| 249 | } |
| 250 | } |
| 251 | else |
| 252 | write("Kein ZT mit dieser Nummer bekannt.\n"); |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | write("Spieler "+capitalize(para)+"\n\n"); |
| 257 | if (o=find_player(para)) |
| 258 | { |
| 259 | potions=sort_array(o->QueryProp(P_POTIONROOMS),#'>); |
| 260 | if (sizeof(potions)) |
| 261 | { |
| 262 | s=""; |
| 263 | for (nr=0;nr<sizeof(potions);nr++) |
| 264 | s+=potions[nr]+", "; |
| 265 | write("Potionrooms:\n"+break_string(s[0..<3],78)+"\n"); |
| 266 | } |
| 267 | else write("Spieler hat keine weiteren Potionrooms.\n"); |
| 268 | potions=sort_array(o->QueryProp(P_KNOWN_POTIONROOMS),#'>); |
| 269 | if (sizeof(potions)) |
| 270 | { |
| 271 | s=""; |
| 272 | for (nr=0;nr<sizeof(potions);nr++) |
| 273 | s+=potions[nr]+", "; |
| 274 | write("Bekannte Potionrooms:\n"+ |
| 275 | break_string(s[0..<3],78)); |
| 276 | } |
| 277 | else write("Spieler hat keine bekannten Potionrooms.\n"); |
| 278 | } |
| 279 | else |
| 280 | write("Kein Spieler mit diesem Namen anwesend.\n"); |
| 281 | } |
| 282 | return 1; |
| 283 | } |
| 284 | |
| 285 | int dump() |
| 286 | { |
| 287 | "/secure/potionmaster"->DumpList(); |
| 288 | printf("Liste wurde erzeugt.\n"); |
| 289 | return 1; |
| 290 | } |
| 291 | |