blob: f1521f7ca68692809f36ae51bb170136322def22 [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
71static mixed _query_localcmds()
72{
73 return ({({"-","ChannelParser", 1, 0}),
74 ({"ebene", "ChannelAdmin", 0, 0}),
75 ({"ebenen", "ChannelAdmin", 1, 0}),
76 });
77}
78
79mixed RegisterChannels()
80{
81 mixed err;
82 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
99mixed RemoveChannels()
100{
101 closure cl;
102 mixed err=({});
103 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
115varargs private string getName(mixed x, int fall) {
116
117 mixed o = closurep(x) ? query_closure_object(x) : x;
118 if(stringp(o) && sizeof(o) && (x = find_object(o)))
119 o = x;
120
121 // Objekte
122 if (objectp(o)) {
123 // Magier sehen unsichtbare nicht nur als "Jemand"
124 if (o->QueryProp(P_INVIS) && IS_LEARNING(this_object()))
125 return "("+capitalize(getuid(o))+")";
126 // Froesche mit Namen versorgen.
127 if (o->QueryProp(P_FROG))
128 return "Frosch "+capitalize(getuid(o));
129 // Default (Unsichtbare als "Jemand" (s. Name()))
130 return o->Name(fall, 2)||"<Unbekannt>";
131 }
132 // Strings
133 else if (stringp(o) && sizeof(o)) {
134 if (o[0] == '/') {
135 // unsichtbare Objekte...
136 int p = strstr(o, "$");
137 if (p != -1) {
Zesstra57a693e2019-01-06 22:08:24 +0100138 // Magier im Magiermodus kriegen den Realnamen, andere nicht.
139 if (IS_LEARNING(this_object()))
140 return o[1..p-1];
141 else
142 return o[p+1..];
MG Mud User88f12472016-06-24 23:31:02 +0200143 }
144 else
Zesstra57a693e2019-01-06 22:08:24 +0100145 // doch nicht unsichtbar
146 return (fall == WESSEN ? o+"s" : o);
MG Mud User88f12472016-06-24 23:31:02 +0200147 }
148 else
149 // nicht unsichtbar
150 return (fall == WESSEN ? o+"s" : o);
151 }
152 // Fall-through
153 return "<Unbekannt>";
154}
155
Arathorn69d6ddd2019-11-25 21:06:34 +0100156// <nonint> unterdrueckt die Ausgabe an den Spieler und liefert den Text
MG Mud User88f12472016-06-24 23:31:02 +0200157// zurueck. Wird nur fuer die Ebenenhistory benutzt.
Arathorn69d6ddd2019-11-25 21:06:34 +0100158string ChannelMessage(<string|object|int>* msg, int nonint)
MG Mud User88f12472016-06-24 23:31:02 +0200159{
160 string channel_message;
161 string channel=msg[0];
Arathorn69d6ddd2019-11-25 21:06:34 +0100162
163 // Wenn eine Ebenenmeldung ausgegeben werden soll, ist msg[1] ein Objekt,
164 // im Fall der History aber ein String. Daher wird <sender> als Union
165 // deklariert. Das ist unproblematisch, weil die beiden Datentypen
166 // komplett getrennte Wege nehmen: ein Objekt wird an ReceiveMsg()
167 // durchgereicht (Ebenenmeldung). Ein String wird direkt in die Meldung
168 // (History) eingebaut, diese an den ChannelParser() zurueckgegeben, der
169 // sie via More() ausgibt.
170 string|object sender=msg[1];
MG Mud User88f12472016-06-24 23:31:02 +0200171 string message=msg[2];
172 int msg_type = msg[3];
173
174 if ( previous_object() != find_object(CHMASTER) &&
175 previous_object() != ME )
176 return 0;
177
178 string sender_name = getName(sender, msg_type == MSG_GEMOTE ? WESSEN : WER);
179 int prepend_indent_flag=QueryProp(P_MESSAGE_PREPEND) ? BS_PREPEND_INDENT : 0;
180 switch(msg_type) {
181 case MSG_EMPTY:
182 channel_message= message+"\n";
183 break;
184 case MSG_GEMOTE:
185 case MSG_EMOTE:
186 channel_message = break_string(sender_name + " "+ message+"]",
187 78, sprintf("[%s:", channel),
188 BS_INDENT_ONCE|prepend_indent_flag);
189 break;
190 case MSG_SAY:
191 default:
192 string presay=sprintf("[%s:%s] ", channel, sender_name);
193 channel_message = break_string(message, max(78,sizeof(presay)+10),
194 presay, prepend_indent_flag);
195 break;
196 }
197 if(nonint)
198 return channel_message;
199
200 // Wenn GMCP sich um Uebertragung der Nachricht kuemmert, wird ReceiveMsg()
Zesstra7ccec732019-01-06 22:10:09 +0100201 // nicht mehr aufgerufen. getName leider nochmal aufrufen, weil GMCP den
202 // Namen im Nominativ braucht.
203 if (msg_type == MSG_GEMOTE)
204 sender_name = getName(sender, WER);
MG Mud User88f12472016-06-24 23:31:02 +0200205 if (GMCP_Channel(channel_message, channel, sender_name) != 1)
206 {
207 // Der Ebenenname muss in Kleinbuchstaben uebergeben werden, damit die
208 // Ignorierepruefung funktioniert. Die ignorierestrings sind naemlich alle
209 // kleingeschrieben.
210 ReceiveMsg(channel_message,
211 MT_COMM|MT_FAR|MSG_DONT_STORE|MSG_DONT_WRAP,
212 MA_CHANNEL"." + lower_case(channel), 0, sender);
213 }
214 return 0;
215}
216
217private void createList(string n, mixed a, mixed m, mixed l)
218{
219 int pos; string sh, *mem;
220 if((pos = member(map(m_values(shortcut), #'lower_case/*'*/), n)) != -1)
221 sh = m_indices(shortcut)[pos];
222 else sh = "";
223 mem=map(a[I_MEMBER],#'getName/*'*/, WER);
224 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{
238 mixed ff;
239 if(!sizeof(ch)) ch = QueryProp(P_STD_CHANNEL);
240 if(shortcut && shortcut[ch]) ch = shortcut[ch];
241 return CHMASTER->find(ch, this_object());
242}
243
244#ifndef DEBUG
245#define DEBUG(x) if (funcall(symbol_function('find_player),"zesstra"))\
246 tell_object(funcall(symbol_function('find_player),"zesstra"),\
Zesstra57a693e2019-01-06 22:08:24 +0100247 "MDBG: "+x+"\n")
MG Mud User88f12472016-06-24 23:31:02 +0200248#endif
249int ChannelParser(string args)
250{
Arathorn6d465642019-11-25 21:06:07 +0100251 mixed ch;
MG Mud User88f12472016-06-24 23:31:02 +0200252 int pos, type, err;
Arathorn6d465642019-11-25 21:06:07 +0100253 string txt, tmp;
254 string|string* cmd = query_verb();
MG Mud User88f12472016-06-24 23:31:02 +0200255 args = _unparsed_args();
256 notify_fail("Benutzung: -<Ebene>[ ]['|:|;]<Text>\n"
257 " -<Ebene>[+|-|?|!|*]\n"
258 " -?\n");
259 if(!cmd && !args) return 0;
260 if(!args) args = "";
261 cmd = cmd[1..];
262 if(sizeof(cmd = regexplode(cmd,
263 "^" CHANNELCMDS "*"
264 "([+-]|\\!|\\?|\\*)*")) > 1)
265 {
266 //z.B. cmd= ({"","allgemein",":testet"})
267 if(sizeof(cmd[1]) > 1 &&
268 strstr("+-?!*", cmd[1][<1..<1]) > -1)
269 tmp = cmd[1][0..<2];
270 else
271 tmp = cmd[1];
272 if(cmd[1] != "?" && cmd[1] != "!")
Zesstra57a693e2019-01-06 22:08:24 +0100273 {
274 ch = getChannel(tmp);
275 if(pointerp(ch))
MG Mud User88f12472016-06-24 23:31:02 +0200276 {
277 notify_fail("Diese Angabe war nicht eindeutig! "
278 "Folgende Ebenen passen:\n"
279 +implode(ch, ", ")+"\n");
280 return 0;
281 }
Zesstra57a693e2019-01-06 22:08:24 +0100282 else if(!ch)
283 return (notify_fail("Die Ebene '"+tmp
284 + "' gibt es nicht!\n"), 0);
285 }
MG Mud User88f12472016-06-24 23:31:02 +0200286 //DEBUG(sprintf("ChanCmd: %O\n",cmd));
287 if (sizeof(cmd[1])) {
288 switch(cmd[1][<1]) {
289 case '+':
290 switch(CHMASTER->join(ch, this_object()))
291 {
292 case E_ACCESS_DENIED:
293 notify_fail("Du darfst an die Ebene '"+ch+"' nicht heran.\n");
294 return 0;
295 case E_ALREADY_JOINED:
296 notify_fail("Du hast diese Ebene schon betreten!\n");
297 return 0;
298 default: break;
299 }
300 write("Du betrittst die Ebene '"+ch+"'.\n");
301 if(member(QueryProp(P_CHANNELS), ch = lower_case(ch)) == -1)
302 SetProp(P_CHANNELS, QueryProp(P_CHANNELS) + ({ ch }));
303 return 1;
304 case '-':
305 switch(CHMASTER->leave(ch, this_object()))
306 {
307 case E_ACCESS_DENIED:
308 write("Du kannst die Ebene '"+ch+"' nicht verlassen.\n");
309 break;
310 case E_NOT_MEMBER:
311 write("Wie willst Du eine Ebene verlassen, welche Du nicht "
312 "betreten hast?\n");
313 break;
314 default:
315 write("Du verlaesst die Ebene '"+ch+"'.\n");
316 SetProp(P_CHANNELS, QueryProp(P_CHANNELS) - ({ lower_case(ch), ch }));
317 break;
318 }
319 return 1;
320 case '!':
321 case '?':
322 {
323 mapping l;
324 if(mappingp(l = CHMASTER->list(this_object())))
Zesstra57a693e2019-01-06 22:08:24 +0100325 {
MG Mud User88f12472016-06-24 23:31:02 +0200326 if(stringp(ch) && sizeof(ch) && pointerp(l[ch = lower_case(ch)]))
327 {
328 int c; object o; string n; string *m;
329 m=sort_array(map(l[ch][I_MEMBER],#'getName/*'*/, WER),#'>/*'*/);
330 m-=({"<MasteR>"});
331 write(l[ch][I_NAME]+", "+funcall(l[ch][I_INFO])+".\n");
332 write("Du siehst "+((c = sizeof(m)) > 0
333 ? (c == 1 ? "ein Gesicht" : c+" Gesichter")
334 : "niemanden")+" auf der Ebene '"
335 +l[ch][I_NAME]+"':\n");
336 write(break_string(implode(m,", "), 78));
337 write((l[ch][I_MASTER] ?
338 getName(l[ch][I_MASTER]) : getName(l[ch][I_ACCESS], WER))
339 +" hat das Sagen auf dieser Ebene.\n");
340 }
341 else
342 {
343 mixed list; list = ({});
344 if(cmd[1][<1] == '!')
345 l -= mkmapping(m_indices(l) - QueryProp(P_CHANNELS));
346 walk_mapping(l, #'createList/*'*/, QueryProp(P_CHANNELS), &list);
347 list = sort_array(list, #'>/*'*/);
348 txt = sprintf("%-12.12' 's [A] %|12' 's (%-3' 's) %-42.42s\n",
349 "Name", "Eigner", "Sp", "Beschreibung")
350 + "-------------------------------------------------------"
351 + "-----------------------\n"
352 + implode(list, "");
353 More(txt);
354 }
Zesstra57a693e2019-01-06 22:08:24 +0100355 }
MG Mud User88f12472016-06-24 23:31:02 +0200356 return 1;
Zesstra57a693e2019-01-06 22:08:24 +0100357
MG Mud User88f12472016-06-24 23:31:02 +0200358 }
359 case '*':
360 {
361 mixed hist; int amount;
362 if(!pointerp(hist = CHMASTER->history(ch, this_object()))
Zesstra57a693e2019-01-06 22:08:24 +0100363 || !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 }
368
369 //(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);*/
377 amount=to_int(cmd[2]);
378 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;
440 mixed pa, tmp;
441 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 }
555 pa = old_explode(args, " ");
556 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