MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | |
| 2 | #pragma strict_types,save_types |
| 3 | #pragma no_clone,no_shadow |
| 4 | |
| 5 | #include <daemon.h> |
| 6 | #include <logging.h> |
| 7 | |
| 8 | static int d_start, d_end, e_start, e_end; |
| 9 | |
| 10 | protected void create() |
| 11 | { |
| 12 | d_end = d_start = e_end = e_start = file_size(__DEBUG_LOG__); |
| 13 | } |
| 14 | |
Zesstra | 39d1d2b | 2020-09-28 23:53:04 +0200 | [diff] [blame] | 15 | int ch_check_access( string ch, object pl, string cmd, string txt ) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 16 | { |
| 17 | mixed tmp; |
| 18 | |
Arathorn | bf1008d | 2020-08-06 21:49:22 +0200 | [diff] [blame] | 19 | if ( ch != "debug" && ch != "entwicklung" && ch != "warnungen" ) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 20 | return 0; |
Arathorn | 52b877e | 2021-03-28 12:48:20 +0200 | [diff] [blame] | 21 | |
| 22 | if (!stringp(txt) || !sizeof(txt)) |
| 23 | return 0; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 24 | |
Arathorn | bf1008d | 2020-08-06 21:49:22 +0200 | [diff] [blame] | 25 | ch = capitalize(ch); |
| 26 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 27 | if( objectp(pl) && query_once_interactive(pl) && query_wiz_level(pl) > 15 ) |
| 28 | switch(cmd){ |
| 29 | case C_FIND: |
| 30 | case C_LIST: |
| 31 | case C_JOIN: |
| 32 | case C_LEAVE: |
| 33 | return 1; |
| 34 | case C_SEND: |
| 35 | // Wer (noch) nicht auf dem Kanal ist, bekommt auch keine |
| 36 | // Ausgabe - sonst gibt es selbige doppelt, da der CHMASTER |
| 37 | // einen automatisch den Kanal betreten laesst ... |
Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 38 | if ( !objectp(pl) || |
| 39 | !pointerp(tmp=({string*})pl->QueryProp(P_CHANNELS)) || |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 40 | member( tmp, lower_case(ch) ) == -1 ) |
| 41 | return 1; |
| 42 | |
| 43 | switch( lower_case(txt) ){ |
| 44 | case "backtrace": |
| 45 | { |
| 46 | string bt, log; |
| 47 | int start, end; |
| 48 | |
| 49 | if ( ch == "Debug" ) { |
| 50 | start = d_start; |
| 51 | end = d_end; |
| 52 | } |
| 53 | else if (ch == "Entwicklung") { |
| 54 | start = e_start; |
| 55 | end = e_end; |
| 56 | } |
| 57 | else if (ch == "Warnungen") { |
| 58 | pl->Message( "[" + ch + ":] Backtrace fuer Warnungen " |
| 59 | "nicht verfuegbar!\n"); |
| 60 | return 0; |
| 61 | } |
| 62 | else return(1); |
| 63 | |
| 64 | if( start >= end ) |
| 65 | bt = "[" + ch + ":] Kein Backtrace verfuegbar!\n"; |
| 66 | else { |
Zesstra | edeb226 | 2019-11-04 23:47:23 +0100 | [diff] [blame] | 67 | log = regreplace( |
| 68 | to_text(read_bytes( __DEBUG_LOG__, start, |
| 69 | min(end-start, 10000)), |
| 70 | "UTF-8") |
| 71 | || "\nFehler beim Einlesen des Debuglogs: " |
| 72 | "Kein Backtrace verfuegbar!\n", |
| 73 | "(Misplaced|current_object|" |
| 74 | "Connection|Host)[^\n]*\n", |
| 75 | "", 1 ); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 76 | bt = "[" + ch + ":] -- BACKTRACE BEGIN --\n" |
| 77 | + log |
| 78 | + "[" + ch + ":] -- BACKTRACE END --\n"; |
| 79 | } |
Zesstra | edeb226 | 2019-11-04 23:47:23 +0100 | [diff] [blame] | 80 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 81 | call_out( symbol_function( "Message", pl ), 0, bt ); |
| 82 | } |
| 83 | break; |
| 84 | |
| 85 | default: |
| 86 | if ( ch != "Warnungen" ) { |
| 87 | pl->Message( "[" + ch + ":] Hilfe...\n" |
| 88 | "[" + ch + ":] Folgende Kommandos stehen zur " |
| 89 | "Verfuegung:\n" |
| 90 | "[" + ch + ":] 'backtrace' -- sendet den " |
| 91 | "Backtrace zum Fehler\n" |
| 92 | "[" + ch + ":] 'hilfe' -- sendet diese " |
| 93 | "Hilfeseite\n"); |
| 94 | } |
| 95 | else { |
| 96 | pl->Message( "[" + ch + ":] Keine Kommandos verfuegbar!\n"); |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | string name() { return "<Debugger>"; } |
| 105 | string Name() { return "<Debugger>"; } |
| 106 | |
| 107 | void ChannelMessage( mixed a ) |
| 108 | { |
| 109 | int fs; |
| 110 | |
| 111 | fs = file_size(__DEBUG_LOG__); |
| 112 | |
| 113 | switch( a[0] ){ |
Arathorn | bf1008d | 2020-08-06 21:49:22 +0200 | [diff] [blame] | 114 | case "debug": |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 115 | if ( fs > d_end && fs > e_end ){ |
| 116 | d_start = max((d_end > e_end ? d_end : e_end),0); |
| 117 | d_end = fs; |
| 118 | } |
| 119 | else if (fs < d_start || fs <= d_end) { |
| 120 | // Debuglog wurde wohl neu geoeffnet. |
| 121 | d_start = d_end = e_start = e_end = fs; |
| 122 | } |
| 123 | break; |
| 124 | |
Arathorn | bf1008d | 2020-08-06 21:49:22 +0200 | [diff] [blame] | 125 | case "entwicklung": |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 126 | if ( fs > d_end && fs > e_end ){ |
| 127 | e_start = max((e_end > d_end ? e_end : d_end),0); |
| 128 | e_end = fs; |
| 129 | } |
| 130 | else if (fs < e_start || fs <= e_end) { |
| 131 | // Debuglog wurde wohl neu geoeffnet. |
| 132 | d_start = d_end = e_start = e_end = fs; |
| 133 | } |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | |