blob: b29240d457c530ee069facfe32d8cce4eed5f13e [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// channel.c -- channel client
4//
5// $Id: channel.c 9404 2015-12-13 00:21:44Z Zesstra $
6#pragma strong_types
7#pragma save_types
8#pragma range_check
9#pragma no_clone
10#pragma pedantic
11
12#define NEED_PROTOTYPES
13#include <util.h>
14#include <thing/properties.h>
15#include <living/comm.h>
16#include <player.h>
17#include <player/comm.h>
18#include <daemon.h>
19#include <player/gmcp.h>
20#undef NEED_PROTOTYPES
21
22#include <wizlevels.h>
23#include <defines.h>
24#include <properties.h>
25#include <sys_debug.h>
26#include <regexp.h>
27
28#define P_SWAP_CHANNELS "swap_channels"
29#define P_CHANNEL_SHORT "short_channels"
30
31#define CHANNELCMDS "[#@%$&()<>a-zA-Z0-9\\-]"
32
33#define DEFAULT_CHANNELS ({"Abenteuer", "Anfaenger","Grats","Tod", "ZT"})
34#define DEFAULT_SHORTCUTS \
35([ \
36 "b":"Abenteuer", \
37 "a":"Allgemein", \
38 "B":"Beileid", \
39 "q":"D-chat", \
40 "G":"Grats", \
41 "M":"Moerder", \
42 "h":"Seher", \
43 "T":"Tod", \
44])
45
46#define WIZARD_SHORTCUTS \
47([ \
48 "P":"D-code", \
49 "D":"Debug", \
50 "O":"Intercode", \
51 "I":"Intermud", \
52 "m":"Magier", \
53])
54
55
56private nosave mapping shortcut;
57private nosave int c_status;
58
59void create()
60{
61 Set(P_CHANNELS, SAVE, F_MODE);
62 Set(P_CHANNELS, DEFAULT_CHANNELS);
63 Set(P_SWAP_CHANNELS, SAVE, F_MODE);
64 Set(P_STD_CHANNEL, "Allgemein");
65 Set(P_STD_CHANNEL, SAVE, F_MODE);
66 Set(P_CHANNEL_SHORT, SAVE, F_MODE);
67 Set(P_CHANNEL_SHORT, DEFAULT_SHORTCUTS
68 + (IS_LEARNER(this_object()) ? WIZARD_SHORTCUTS : ([])));
69}
70
Arathorn00764692019-11-27 22:09:31 +010071static <int|string>** _query_localcmds()
MG Mud User88f12472016-06-24 23:31:02 +020072{
73 return ({({"-","ChannelParser", 1, 0}),
74 ({"ebene", "ChannelAdmin", 0, 0}),
75 ({"ebenen", "ChannelAdmin", 1, 0}),
76 });
77}
78
Arathorn00764692019-11-27 22:09:31 +010079string* RegisterChannels()
MG Mud User88f12472016-06-24 23:31:02 +020080{
Arathorn00764692019-11-27 22:09:31 +010081 string* err;
MG Mud User88f12472016-06-24 23:31:02 +020082 if(extern_call() &&
83 previous_object() != find_object(CHMASTER)) return;
84 c_status = 0;
85 shortcut = QueryProp(P_CHANNEL_SHORT);
86 SetProp(P_CHANNELS, map(QueryProp(P_CHANNELS) || ({}),
Zesstra57a693e2019-01-06 22:08:24 +010087 #'lower_case));
MG Mud User88f12472016-06-24 23:31:02 +020088 err = filter(QueryProp(P_CHANNELS),
89 symbol_function("join", CHMASTER),
90 this_object());
91 if(QueryProp(P_LEVEL) < 5) return err;
92 while(sizeof(err)) {
93 CHMASTER->new(err[0], this_object());
94 err[0..0] = ({});
95 }
96 return err;
97}
98
Arathorn00764692019-11-27 22:09:31 +010099string* RemoveChannels()
MG Mud User88f12472016-06-24 23:31:02 +0200100{
101 closure cl;
Arathorn00764692019-11-27 22:09:31 +0100102 string* err=({});
MG Mud User88f12472016-06-24 23:31:02 +0200103 if(extern_call() &&
104 previous_object() != find_object(CHMASTER)) return;
105 if(!c_status) c_status = 1;
106 else return ({});
107 cl=symbol_function("leave", CHMASTER);
108 if (closurep(cl)) {
109 err = filter(QueryProp(P_CHANNELS), cl, this_object());
110 SetProp(P_CHANNELS, QueryProp(P_CHANNELS) - err);
111 }
112 return err;
113}
114
Arathorn00764692019-11-27 22:09:31 +0100115varargs private string getName(string|object|closure x, int fall) {
116 string|object o = closurep(x) ? query_closure_object(x) : x;
117 if(stringp(o) && sizeof(o) && (x = find_object(o)))
MG Mud User88f12472016-06-24 23:31:02 +0200118 o = x;
119
120 // Objekte
121 if (objectp(o)) {
122 // Magier sehen unsichtbare nicht nur als "Jemand"
123 if (o->QueryProp(P_INVIS) && IS_LEARNING(this_object()))
124 return "("+capitalize(getuid(o))+")";
125 // Froesche mit Namen versorgen.
126 if (o->QueryProp(P_FROG))
127 return "Frosch "+capitalize(getuid(o));
128 // Default (Unsichtbare als "Jemand" (s. Name()))
129 return o->Name(fall, 2)||"<Unbekannt>";
130 }
131 // Strings
132 else if (stringp(o) && sizeof(o)) {
133 if (o[0] == '/') {
134 // unsichtbare Objekte...
135 int p = strstr(o, "$");
136 if (p != -1) {
Zesstra57a693e2019-01-06 22:08:24 +0100137 // Magier im Magiermodus kriegen den Realnamen, andere nicht.
138 if (IS_LEARNING(this_object()))
139 return o[1..p-1];
140 else
141 return o[p+1..];
MG Mud User88f12472016-06-24 23:31:02 +0200142 }
143 else
Zesstra57a693e2019-01-06 22:08:24 +0100144 // doch nicht unsichtbar
145 return (fall == WESSEN ? o+"s" : o);
MG Mud User88f12472016-06-24 23:31:02 +0200146 }
147 else
148 // nicht unsichtbar
149 return (fall == WESSEN ? o+"s" : o);
150 }
151 // Fall-through
152 return "<Unbekannt>";
153}
154
Arathorn69d6ddd2019-11-25 21:06:34 +0100155// <nonint> unterdrueckt die Ausgabe an den Spieler und liefert den Text
MG Mud User88f12472016-06-24 23:31:02 +0200156// zurueck. Wird nur fuer die Ebenenhistory benutzt.
Arathorn69d6ddd2019-11-25 21:06:34 +0100157string ChannelMessage(<string|object|int>* msg, int nonint)
MG Mud User88f12472016-06-24 23:31:02 +0200158{
159 string channel_message;
160 string channel=msg[0];
Arathorn69d6ddd2019-11-25 21:06:34 +0100161
162 // Wenn eine Ebenenmeldung ausgegeben werden soll, ist msg[1] ein Objekt,
163 // im Fall der History aber ein String. Daher wird <sender> als Union
164 // deklariert. Das ist unproblematisch, weil die beiden Datentypen
165 // komplett getrennte Wege nehmen: ein Objekt wird an ReceiveMsg()
166 // durchgereicht (Ebenenmeldung). Ein String wird direkt in die Meldung
167 // (History) eingebaut, diese an den ChannelParser() zurueckgegeben, der
168 // sie via More() ausgibt.
169 string|object sender=msg[1];
MG Mud User88f12472016-06-24 23:31:02 +0200170 string message=msg[2];
171 int msg_type = msg[3];
172
173 if ( previous_object() != find_object(CHMASTER) &&
174 previous_object() != ME )
175 return 0;
176
177 string sender_name = getName(sender, msg_type == MSG_GEMOTE ? WESSEN : WER);
178 int prepend_indent_flag=QueryProp(P_MESSAGE_PREPEND) ? BS_PREPEND_INDENT : 0;
179 switch(msg_type) {
180 case MSG_EMPTY:
181 channel_message= message+"\n";
182 break;
183 case MSG_GEMOTE:
184 case MSG_EMOTE:
185 channel_message = break_string(sender_name + " "+ message+"]",
186 78, sprintf("[%s:", channel),
187 BS_INDENT_ONCE|prepend_indent_flag);
188 break;
189 case MSG_SAY:
190 default:
191 string presay=sprintf("[%s:%s] ", channel, sender_name);
192 channel_message = break_string(message, max(78,sizeof(presay)+10),
193 presay, prepend_indent_flag);
194 break;
195 }
196 if(nonint)
197 return channel_message;
198
199 // Wenn GMCP sich um Uebertragung der Nachricht kuemmert, wird ReceiveMsg()
Zesstra7ccec732019-01-06 22:10:09 +0100200 // nicht mehr aufgerufen. getName leider nochmal aufrufen, weil GMCP den
201 // Namen im Nominativ braucht.
202 if (msg_type == MSG_GEMOTE)
203 sender_name = getName(sender, WER);
MG Mud User88f12472016-06-24 23:31:02 +0200204 if (GMCP_Channel(channel_message, channel, sender_name) != 1)
205 {
206 // Der Ebenenname muss in Kleinbuchstaben uebergeben werden, damit die
207 // Ignorierepruefung funktioniert. Die ignorierestrings sind naemlich alle
208 // kleingeschrieben.
209 ReceiveMsg(channel_message,
210 MT_COMM|MT_FAR|MSG_DONT_STORE|MSG_DONT_WRAP,
211 MA_CHANNEL"." + lower_case(channel), 0, sender);
212 }
213 return 0;
214}
215
216private void createList(string n, mixed a, mixed m, mixed l)
217{
Arathorn00764692019-11-27 22:09:31 +0100218 int pos = member(map(m_values(shortcut), #'lower_case/*'*/), n);
219 string sh = "";
220 if(pos != -1)
MG Mud User88f12472016-06-24 23:31:02 +0200221 sh = m_indices(shortcut)[pos];
Arathorn00764692019-11-27 22:09:31 +0100222
223 string* mem=map(a[I_MEMBER],#'getName/*'*/, WER);
MG Mud User88f12472016-06-24 23:31:02 +0200224 mem-=({"<MasteR>"});
225 l += ({ sprintf("%-12.12'.'s %c[%-1.1s] %|12.12' 's (%-|3' 'd) %-42.42s\n",
226 a[I_NAME], (member(m, n) != -1 ? '*' : ' '), sh,
227 a[I_MASTER] ?
228 getName(a[I_MASTER]) : getName(a[I_ACCESS]),
229 sizeof(mem),
230 (closurep(a[I_INFO]) && objectp(query_closure_object(a[I_INFO]))) ?
231 funcall(a[I_INFO]) || "- Keine Beschreibung -" :
232 (stringp(a[I_INFO]) ? a[I_INFO] : "- Keine Beschreibung -")
233 ) });
234}
235
236private mixed getChannel(string ch)
237{
Arathorn00764692019-11-27 22:09:31 +0100238 if(!sizeof(ch))
239 ch = QueryProp(P_STD_CHANNEL);
240 if(shortcut && shortcut[ch])
241 ch = shortcut[ch];
MG Mud User88f12472016-06-24 23:31:02 +0200242 return CHMASTER->find(ch, this_object());
243}
244
245#ifndef DEBUG
246#define DEBUG(x) if (funcall(symbol_function('find_player),"zesstra"))\
247 tell_object(funcall(symbol_function('find_player),"zesstra"),\
Zesstra57a693e2019-01-06 22:08:24 +0100248 "MDBG: "+x+"\n")
MG Mud User88f12472016-06-24 23:31:02 +0200249#endif
250int ChannelParser(string args)
251{
Arathorn6d465642019-11-25 21:06:07 +0100252 mixed ch;
MG Mud User88f12472016-06-24 23:31:02 +0200253 int pos, type, err;
Arathorn6d465642019-11-25 21:06:07 +0100254 string txt, tmp;
255 string|string* cmd = query_verb();
MG Mud User88f12472016-06-24 23:31:02 +0200256 args = _unparsed_args();
257 notify_fail("Benutzung: -<Ebene>[ ]['|:|;]<Text>\n"
258 " -<Ebene>[+|-|?|!|*]\n"
259 " -?\n");
260 if(!cmd && !args) return 0;
261 if(!args) args = "";
262 cmd = cmd[1..];
263 if(sizeof(cmd = regexplode(cmd,
264 "^" CHANNELCMDS "*"
265 "([+-]|\\!|\\?|\\*)*")) > 1)
266 {
267 //z.B. cmd= ({"","allgemein",":testet"})
268 if(sizeof(cmd[1]) > 1 &&
269 strstr("+-?!*", cmd[1][<1..<1]) > -1)
270 tmp = cmd[1][0..<2];
271 else
272 tmp = cmd[1];
273 if(cmd[1] != "?" && cmd[1] != "!")
Zesstra57a693e2019-01-06 22:08:24 +0100274 {
275 ch = getChannel(tmp);
276 if(pointerp(ch))
MG Mud User88f12472016-06-24 23:31:02 +0200277 {
278 notify_fail("Diese Angabe war nicht eindeutig! "
279 "Folgende Ebenen passen:\n"
280 +implode(ch, ", ")+"\n");
281 return 0;
282 }
Zesstra57a693e2019-01-06 22:08:24 +0100283 else if(!ch)
284 return (notify_fail("Die Ebene '"+tmp
285 + "' gibt es nicht!\n"), 0);
286 }
MG Mud User88f12472016-06-24 23:31:02 +0200287 //DEBUG(sprintf("ChanCmd: %O\n",cmd));
288 if (sizeof(cmd[1])) {
289 switch(cmd[1][<1]) {
290 case '+':
291 switch(CHMASTER->join(ch, this_object()))
292 {
293 case E_ACCESS_DENIED:
294 notify_fail("Du darfst an die Ebene '"+ch+"' nicht heran.\n");
295 return 0;
296 case E_ALREADY_JOINED:
297 notify_fail("Du hast diese Ebene schon betreten!\n");
298 return 0;
299 default: break;
300 }
301 write("Du betrittst die Ebene '"+ch+"'.\n");
302 if(member(QueryProp(P_CHANNELS), ch = lower_case(ch)) == -1)
303 SetProp(P_CHANNELS, QueryProp(P_CHANNELS) + ({ ch }));
304 return 1;
305 case '-':
306 switch(CHMASTER->leave(ch, this_object()))
307 {
308 case E_ACCESS_DENIED:
309 write("Du kannst die Ebene '"+ch+"' nicht verlassen.\n");
310 break;
311 case E_NOT_MEMBER:
312 write("Wie willst Du eine Ebene verlassen, welche Du nicht "
313 "betreten hast?\n");
314 break;
315 default:
316 write("Du verlaesst die Ebene '"+ch+"'.\n");
317 SetProp(P_CHANNELS, QueryProp(P_CHANNELS) - ({ lower_case(ch), ch }));
318 break;
319 }
320 return 1;
321 case '!':
322 case '?':
323 {
324 mapping l;
325 if(mappingp(l = CHMASTER->list(this_object())))
Zesstra57a693e2019-01-06 22:08:24 +0100326 {
MG Mud User88f12472016-06-24 23:31:02 +0200327 if(stringp(ch) && sizeof(ch) && pointerp(l[ch = lower_case(ch)]))
328 {
329 int c; object o; string n; string *m;
330 m=sort_array(map(l[ch][I_MEMBER],#'getName/*'*/, WER),#'>/*'*/);
331 m-=({"<MasteR>"});
332 write(l[ch][I_NAME]+", "+funcall(l[ch][I_INFO])+".\n");
333 write("Du siehst "+((c = sizeof(m)) > 0
334 ? (c == 1 ? "ein Gesicht" : c+" Gesichter")
335 : "niemanden")+" auf der Ebene '"
336 +l[ch][I_NAME]+"':\n");
337 write(break_string(implode(m,", "), 78));
338 write((l[ch][I_MASTER] ?
339 getName(l[ch][I_MASTER]) : getName(l[ch][I_ACCESS], WER))
340 +" hat das Sagen auf dieser Ebene.\n");
341 }
342 else
343 {
Arathorn00764692019-11-27 22:09:31 +0100344 string* list = ({});
MG Mud User88f12472016-06-24 23:31:02 +0200345 if(cmd[1][<1] == '!')
346 l -= mkmapping(m_indices(l) - QueryProp(P_CHANNELS));
347 walk_mapping(l, #'createList/*'*/, QueryProp(P_CHANNELS), &list);
348 list = sort_array(list, #'>/*'*/);
349 txt = sprintf("%-12.12' 's [A] %|12' 's (%-3' 's) %-42.42s\n",
350 "Name", "Eigner", "Sp", "Beschreibung")
351 + "-------------------------------------------------------"
352 + "-----------------------\n"
353 + implode(list, "");
354 More(txt);
355 }
Zesstra57a693e2019-01-06 22:08:24 +0100356 }
MG Mud User88f12472016-06-24 23:31:02 +0200357 return 1;
Zesstra57a693e2019-01-06 22:08:24 +0100358
MG Mud User88f12472016-06-24 23:31:02 +0200359 }
360 case '*':
361 {
Arathorn00764692019-11-27 22:09:31 +0100362 mixed hist = CHMASTER->history(ch, this_object());
363 if(!pointerp(hist) || !sizeof(hist))
MG Mud User88f12472016-06-24 23:31:02 +0200364 {
365 write("Es ist keine Geschichte fuer '"+ch+"' verfuegbar.\n");
366 return 1;
367 }
Arathorn00764692019-11-27 22:09:31 +0100368
MG Mud User88f12472016-06-24 23:31:02 +0200369 //(Zesstra) cmd hat offenbar immer 3 Elemente...
370 //bei -all* ({"","all*",""})
371 //bei -all*10 ({"","all*,"10"})
372 //also ist bei -all* amount immer == 0 und es funktioniert eher zufaellig.
373 /*if(sizeof(cmd) > 2)
374 amount = to_int(cmd[2]);
375 else
376 amount=sizeof(hist);*/
Arathorn00764692019-11-27 22:09:31 +0100377 int amount=to_int(cmd[2]);
MG Mud User88f12472016-06-24 23:31:02 +0200378 if (amount <= 0 || amount >= sizeof(hist))
379 amount=sizeof(hist);
380
381 txt = "Folgendes ist auf '"+ch+"' passiert:\n"
382 + implode(map(hist[<amount..], #'ChannelMessage/*'*/, 1), "");
383 More(txt);
384 return 1;
385 }
386 default:
387 break;
388 }
389 }
390 }
391 if(sizeof(cmd = implode(cmd[2..], "")))
392 args = cmd + (sizeof(args) ? " " : "") + args;
393
394 // KOntrollchars ausfiltern.
395 args = regreplace(args,"[[:cntrl:]]","",RE_PCRE|RE_GLOBAL);
396 if(!sizeof(args)) return 0;
397
398 //Wenn cmd leer ist: MSG_SAY
399 if (!sizeof(cmd)) type=MSG_SAY;
400 else {
401 switch(cmd[0])
402 {
403 case ':' :
404 type = MSG_EMOTE;
405 args = args[1..];
406 break;
407 case ';' :
408 type = MSG_GEMOTE;
409 args = args[1..];
410 break;
411 case '\'':
412 args = args[1..];
413 default : type = MSG_SAY; break;
414 }
415 }
416 if(!ch || !sizeof(ch)) ch = QueryProp(P_STD_CHANNEL);
417 if((err = CHMASTER->send(ch, this_object(), args, type)) < 0)
418 if(!(err = CHMASTER->join(ch, this_object())))
419 {
420 if(member(QueryProp(P_CHANNELS), ch = lower_case(ch)) == -1)
421 SetProp(P_CHANNELS, QueryProp(P_CHANNELS) + ({ ch }));
422 err = CHMASTER->send(ch, this_object(), args, type);
423 }
424
425 switch(err)
426 {
427 case E_ACCESS_DENIED:
428 notify_fail("Auf der Ebene '"+ch+"' darfst Du nichts sagen.\n");
429 return 0;
430 case E_NOT_MEMBER:
431 notify_fail("Du hast die Ebene '"+ch+"' nicht betreten!\n");
432 return 0;
433 }
434 return 1;
435}
436
437int ChannelAdmin(string args)
438{
439 string n, descr, sh, cn;
Arathorn00764692019-11-27 22:09:31 +0100440 mixed tmp;
MG Mud User88f12472016-06-24 23:31:02 +0200441 args = _unparsed_args();
442 notify_fail("Benutzung: ebene <Abkuerzung>=<Ebene>\n"
443 " ebene <Abkuerzung>=\n"
444 " ebene abkuerzungen [standard]\n"
445 " ebene standard <Ebene>\n"
446 " ebene an|ein|aus\n"
447 +(QueryProp(P_LEVEL) >= 5 ?
448 " ebene neu <Name> <Bezeichnung>\n"
449 " ebene beschreibung <Name> <Beschreibung>\n" : "")
450 +(IS_ARCH(this_object()) ?
451 " ebene kill <Name>\n"
Zesstra57a693e2019-01-06 22:08:24 +0100452 " ebene clear <Name>\n": ""));
MG Mud User88f12472016-06-24 23:31:02 +0200453 if(!args || !sizeof(args)) return 0;
454 if(sscanf(args, "kill %s", n) && IS_ARCH(this_object()))
455 {
456 if(!(cn = CHMASTER->find(n, this_object()))) cn = n;
457 switch(CHMASTER->remove(cn, this_object()))
458 {
459 case E_ACCESS_DENIED:
460 notify_fail("Die Ebene '"+cn+"' lies sich nicht entfernen!\n");
461 return 0;
462 }
463 write("Du entfernst die Ebene '"+cn+"'.\n");
464 return 1;
465 }
466 if(sscanf(args, "clear %s", n) && IS_ARCH(this_object()))
467 {
468 if(!(cn = CHMASTER->find(n, this_object()))) cn = n;
469 switch(CHMASTER->clear_history(cn, this_object()))
470 {
471 case E_ACCESS_DENIED:
472 notify_fail("Der Verlauf zur Ebene '"+cn+"' lies sich nicht entfernen!\n");
473 return 0;
474 }
475 write("Du entfernst den Verlauf zur Ebene '"+cn+"'.\n");
476 return 1;
477 }
478 if(sscanf(args, "neu %s %s", n, descr) == 2)
479 {
480 mixed x;
481 if(QueryProp(P_LEVEL) < 5)
482 return (notify_fail("Neue Ebenen zu erstellen ist dir verwehrt.\n"), 0);
483 if(!sizeof(regexp(({ n }), "^" CHANNELCMDS CHANNELCMDS "*")))
484 return (notify_fail("Der Name '"+n+"' ist nicht konform!\n"), 0);
485 if (sizeof(n) > 20 )
486 return(notify_fail("Der Name '"+n+"' ist zu lang.\n"), 0);
487 switch(x = CHMASTER->new(n, this_object(), descr))
488 {
489 case E_ACCESS_DENIED:
490 notify_fail("Diese Ebene darfst du nicht erschaffen!\n"); break;
491 default:
492 write("Du erschaffst die Ebene '"+n+"'.\n");
493 SetProp(P_CHANNELS, QueryProp(P_CHANNELS) + ({ lower_case(n) }));
494 return 1;
495 }
496 }
497 if(sscanf(args, "beschreibung %s %s", n, descr) == 2)
498 {
499 mixed ch;
500 cn = CHMASTER->find(n, this_object());
501 if(!cn || pointerp(cn))
502 return (notify_fail("Die Ebene '"+n+"' existiert nicht oder die Angabe "
503 "war nicht eindeutig.\n"), 0);
504 ch = CHMASTER->list(this_object());
505 if(ch[lower_case(cn)][I_MASTER] != this_object())
506 return (notify_fail("Du bist nicht berechtigt die Beschreibung der Ebene"
507 " '"+cn+"' zu aendern.\n"), 0);
508 ch[lower_case(cn)][I_INFO] = descr;
509 write("Die Ebene '"+cn+"' hat ab sofort die Beschreibung:\n"+descr+"\n");
510 return 1;
511 }
512 if(sscanf(args, "%s=%s", sh, n) == 2 && sizeof(n))
513 {
514 mapping sc;
515 if(pointerp(tmp = CHMASTER->find(n, this_object())) || !tmp)
516 return (notify_fail("Benutzung: ebene <Abkuerzung>=<Ebene>\n"
517 +(pointerp(tmp) ? implode(tmp, ", ") + "\n" :
518 "Ebene '"+n+"' nicht gefunden!\n")), 0);
519 sc = QueryProp(P_CHANNEL_SHORT);
520 if(!sc) sc = ([]);
521 sc[sh] = tmp;
522 SetProp(P_CHANNEL_SHORT, sc);
523 shortcut = QueryProp(P_CHANNEL_SHORT);
524 write("'"+sh+"' wird jetzt als Abkuerzung fuer '"+tmp+"' anerkannt.\n");
525 return 1;
526 }
527 if(sscanf(args, "%s=", sh))
528 {
529 SetProp(P_CHANNEL_SHORT, m_copy_delete(QueryProp(P_CHANNEL_SHORT) || ([]), sh));
530 shortcut = QueryProp(P_CHANNEL_SHORT);
531 write("Du loeschst die Abkuerzung '"+sh+"'.\n");
532 return 1;
533 }
534 if(args == "an" || args == "ein")
535 {
536 mixed excl;
537 if(pointerp(QueryProp(P_SWAP_CHANNELS)))
538 SetProp(P_CHANNELS, QueryProp(P_SWAP_CHANNELS));
539 else
540 SetProp(P_CHANNELS, m_indices(CHMASTER->list(this_object())));
541 excl = RegisterChannels();
542 write("Du schaltest folgende Ebenen ein:\n"
543 +break_string(implode(QueryProp(P_CHANNELS) - excl, ", "), 78));
544 SetProp(P_SWAP_CHANNELS, 0);
545 return 1;
546 }
547 if(args == "aus")
548 {
549 SetProp(P_SWAP_CHANNELS, QueryProp(P_CHANNELS));
550 RemoveChannels();
551 SetProp(P_CHANNELS, ({}));
552 write("Du stellst die Ebenen ab.\n");
553 return 1;
554 }
Arathorn00764692019-11-27 22:09:31 +0100555 string* pa = old_explode(args, " ");
MG Mud User88f12472016-06-24 23:31:02 +0200556 if(!strstr("abkuerzungen", pa[0]))
557 {
558 string txt; txt = "";
559 if(sizeof(pa) > 1 && !strstr("standard", pa[1]))
560 {
561 write("Die Standard Abkuerzungen werden gesetzt.\n");
562 SetProp(P_CHANNEL_SHORT, DEFAULT_SHORTCUTS
563 + (IS_LEARNER(this_object()) ? WIZARD_SHORTCUTS : ([])));
564 }
Arathorndc28afc2018-11-26 22:20:59 +0100565 foreach(string abk, string ch_name : QueryProp(P_CHANNEL_SHORT)) {
566 txt += sprintf("%5.5s = %s\n", abk, ch_name);
567 }
MG Mud User88f12472016-06-24 23:31:02 +0200568 txt = sprintf("Folgende Abkuerzungen sind definiert:\n%-78#s\n",
569 implode(sort_array(old_explode(txt, "\n"), #'>/*'*/), "\n"));
570 More(txt);
571 return 1;
572 }
573 if(!strstr("standard", pa[0]))
574 if(sizeof(pa) < 2)
575 return (notify_fail("Benutzung: ebene standard <Ebene>\n"
576 +(QueryProp(P_STD_CHANNEL)
577 ? "Momentan ist '"+QueryProp(P_STD_CHANNEL)
578 +"' eingestellt.\n"
579 : "Es ist keine Standardebene eingestellt.\n")),0);
580 else
581 if(pointerp(tmp = CHMASTER->find(pa[1], this_object())))
582 return (notify_fail("Das war keine eindeutige Angabe! "
583 "Folgende Ebenen passen:\n"
584 +break_string(implode(tmp, ", "), 78)), 0);
585 else
586 if(!tmp) return (notify_fail("Ebene '"+pa[1]+"' nicht gefunden!\n"),0);
587 else
588 {
589 write("'"+tmp+"' ist jetzt die Standardebene.\n");
590 SetProp(P_STD_CHANNEL, tmp);
591 return 1;
592 }
593 return(0);
594}
595