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 | |
Zesstra | d39f73d | 2018-11-09 00:01:15 +0100 | [diff] [blame] | 10 | inherit "/std/secure_thing"; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 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); |
Arathorn | 4392248 | 2021-02-28 14:49:51 +0100 | [diff] [blame] | 49 | AddId(({"tool", "ptool","potiontool","potion-tool"})); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 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 | { |
Arathorn | 812e178 | 2021-04-02 14:59:48 +0200 | [diff] [blame^] | 63 | int nr, next; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 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 | } |
Arathorn | 812e178 | 2021-04-02 14:59:48 +0200 | [diff] [blame^] | 83 | |
| 84 | printf("Raum aktiviert in Liste %d\n", nr); |
| 85 | dump(); |
| 86 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 87 | return 1; |
| 88 | } |
| 89 | |
| 90 | int changepath(string number) |
| 91 | { |
| 92 | int nr,neu; |
| 93 | string room; |
| 94 | mixed roomold; |
| 95 | if (!secure()) |
| 96 | { printf("Fehler: -1\n"); return -1; } |
| 97 | if (!query_once_interactive(environment())) |
| 98 | { printf("Fehler: -2\n"); return -2; } |
| 99 | if (!number) |
| 100 | { printf("Fehler: -3\n"); return -3; } |
| 101 | sscanf(number, "%d", nr); |
| 102 | if (!intp(nr)) |
| 103 | { printf("Fehler: -4\n"); return -4; } |
| 104 | room = object_name(environment(environment(this_object()))); |
| 105 | roomold = "/secure/potionmaster"->GetFilenameByNumber(nr); |
| 106 | if (roomold==-1) |
| 107 | { printf("Fehler: -5\n"); return -5; } |
| 108 | neu = "/secure/potionmaster"->ChangeRoomPath(roomold,room); |
| 109 | if (neu>0) |
| 110 | { |
| 111 | printf("ZT %d durch aktuellen Raum ersetzt.\n", neu); |
| 112 | dump(); |
| 113 | } |
| 114 | else |
| 115 | printf("ZT %d konnte nicht ersetzt werden, Ergebnis: %d\n", nr,neu); |
| 116 | return 1; |
| 117 | } |
| 118 | |
| 119 | int setlist(string number) |
| 120 | { |
Arathorn | 812e178 | 2021-04-02 14:59:48 +0200 | [diff] [blame^] | 121 | int nr, active; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 122 | string room; |
| 123 | if (!secure()) |
| 124 | { printf("Fehler: -1\n"); return -1; } |
| 125 | if (!query_once_interactive(environment())) |
| 126 | { printf("Fehler: -2\n"); return -2; } |
| 127 | if (!number) |
| 128 | { printf("Fehler: -3\n"); return -3; } |
| 129 | sscanf(number, "%d", nr); |
| 130 | if (!intp(nr) || nr<0 || nr>7) |
| 131 | { printf("Fehler: -4\n"); return -4; } |
| 132 | room = object_name(environment(environment(this_object()))); |
| 133 | active = "/secure/potionmaster"->SetListNr(room, nr); |
| 134 | if (active>=0) |
| 135 | { |
| 136 | printf("Raum aktiviert in Liste %d\n", nr); |
| 137 | dump(); |
| 138 | } |
| 139 | else |
| 140 | printf("Fehler beim Aktivieren, Ergebnis: %d\n", active); |
| 141 | return 1; |
| 142 | } |
| 143 | |
| 144 | int activate() |
| 145 | { |
Arathorn | 812e178 | 2021-04-02 14:59:48 +0200 | [diff] [blame^] | 146 | int active; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 147 | string room; |
| 148 | |
| 149 | if (!secure()) |
| 150 | { printf("Fehler: -1\n"); return -1; } |
| 151 | if (!query_once_interactive(environment())) |
| 152 | { printf("Fehler: -2\n"); return -2; } |
| 153 | room = object_name(environment(environment(this_object()))); |
| 154 | active = "/secure/potionmaster"->ActivateRoom(room); |
| 155 | if (active>=0) |
| 156 | { |
| 157 | printf("Raum aktiviert in Liste %d\n", active); |
| 158 | dump(); |
| 159 | } |
| 160 | else |
| 161 | printf("Fehler beim Aktivieren, Ergebnis: %d\n", active); |
| 162 | return 1; |
| 163 | } |
| 164 | |
| 165 | int deactivate() |
| 166 | { |
| 167 | int deactive; |
| 168 | string room; |
| 169 | |
| 170 | if (!secure()) |
| 171 | { printf("Fehler: -1\n"); return -1; } |
| 172 | if (!query_once_interactive(environment())) |
| 173 | { printf("Fehler: -2\n"); return -2; } |
| 174 | room = object_name(environment(environment(this_object()))); |
| 175 | deactive = "/secure/potionmaster"->DeactivateRoom(room); |
| 176 | if (deactive>=0) |
| 177 | { |
| 178 | printf("Raum deaktiviert in Liste %d\n",deactive); |
| 179 | dump(); |
| 180 | } |
| 181 | else |
| 182 | printf("Fehler beim Deaktivieren, Ergebnis: %d\n", deactive); |
| 183 | return 1; |
| 184 | } |
| 185 | |
| 186 | int info(string para) |
| 187 | { |
| 188 | int info,nr; |
| 189 | string s; |
| 190 | object room,o; |
| 191 | mixed m,*potions; |
| 192 | if (!secure()) |
| 193 | { printf("Fehler: -1\n"); return -1; } |
| 194 | if (!query_once_interactive(environment())) |
| 195 | { printf("Fehler: -2\n"); return -2; } |
| 196 | if (!para || para=="") |
| 197 | { |
| 198 | room = environment(environment(this_object())); |
| 199 | info = "/secure/potionmaster"->HasPotion(room); |
| 200 | if (info>=0) |
| 201 | { |
| 202 | printf("Raum hat ZT mit Nr: %d\n\n",info); |
| 203 | nr = "/secure/potionmaster"->GetListByNumber(info); |
| 204 | if (nr>=0) |
| 205 | printf("ZT aktiv in Liste: %d\n\n",nr); |
| 206 | else |
| 207 | { |
| 208 | nr = "/secure/potionmaster"->GetInactListByNumber(info); |
| 209 | if (nr>=0) |
| 210 | printf("ZT INaktiv in Liste: %d\n\n",nr); |
| 211 | else |
| 212 | printf("ZT INaktiv\n\n"); |
| 213 | } |
| 214 | if (info>=0 && s=read_file("/secure/ARCH/ZT/"+info+".zt")) |
| 215 | { |
| 216 | write("Tip:\n"+s); |
| 217 | } |
| 218 | } |
| 219 | else |
| 220 | printf("Raum hat keinen ZT eingetragen.\n"); |
| 221 | } |
| 222 | else |
| 223 | if (sscanf(para,"%d",info)==1) |
| 224 | { |
| 225 | printf("ZT mit Nummer: %d\n\n",info); |
| 226 | m = "/secure/potionmaster"->GetFilenameByNumber(info); |
| 227 | if (m!=-1) |
| 228 | { |
| 229 | write("Filename: "+m+"\n\n"); |
| 230 | nr = "/secure/potionmaster"->GetListByNumber(info); |
| 231 | if (nr>=0) |
| 232 | printf("ZT aktiv in Liste: %d\n\n",nr); |
| 233 | else |
| 234 | { |
| 235 | nr = "/secure/potionmaster"->GetInactListByNumber(info); |
| 236 | if (nr>=0) |
| 237 | printf("ZT INaktiv in Liste: %d\n\n",nr); |
| 238 | else |
| 239 | printf("ZT INaktiv\n\n"); |
| 240 | } |
| 241 | if (info>=0 && s=read_file("/secure/ARCH/ZT/"+info+".zt")) |
| 242 | { |
| 243 | write("Tip:\n"+s); |
| 244 | } |
| 245 | } |
| 246 | else |
| 247 | write("Kein ZT mit dieser Nummer bekannt.\n"); |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | write("Spieler "+capitalize(para)+"\n\n"); |
| 252 | if (o=find_player(para)) |
| 253 | { |
| 254 | potions=sort_array(o->QueryProp(P_POTIONROOMS),#'>); |
| 255 | if (sizeof(potions)) |
| 256 | { |
| 257 | s=""; |
| 258 | for (nr=0;nr<sizeof(potions);nr++) |
| 259 | s+=potions[nr]+", "; |
| 260 | write("Potionrooms:\n"+break_string(s[0..<3],78)+"\n"); |
| 261 | } |
| 262 | else write("Spieler hat keine weiteren Potionrooms.\n"); |
| 263 | potions=sort_array(o->QueryProp(P_KNOWN_POTIONROOMS),#'>); |
| 264 | if (sizeof(potions)) |
| 265 | { |
| 266 | s=""; |
| 267 | for (nr=0;nr<sizeof(potions);nr++) |
| 268 | s+=potions[nr]+", "; |
| 269 | write("Bekannte Potionrooms:\n"+ |
| 270 | break_string(s[0..<3],78)); |
| 271 | } |
| 272 | else write("Spieler hat keine bekannten Potionrooms.\n"); |
| 273 | } |
| 274 | else |
| 275 | write("Kein Spieler mit diesem Namen anwesend.\n"); |
| 276 | } |
| 277 | return 1; |
| 278 | } |
| 279 | |
| 280 | int dump() |
| 281 | { |
| 282 | "/secure/potionmaster"->DumpList(); |
| 283 | printf("Liste wurde erzeugt.\n"); |
| 284 | return 1; |
| 285 | } |
| 286 | |