| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | // MorgenGrauen MUDlib |
| 2 | // |
| 3 | // login.c -- Object for players just logging in |
| 4 | // |
| 5 | // $Id: login.c 9245 2015-06-04 13:04:39Z Arathorn $ |
| 6 | |
| 7 | /* |
| 8 | * secure/login.c |
| 9 | * |
| 10 | * This object is cloned for every user trying to log in |
| 11 | * We are still running root. |
| 12 | * |
| 13 | * login.c looks up the username in the secure/PASSWD file. If it is |
| 14 | * found, the password is checked. If the user is already logged in, |
| 15 | * he will be reconnected to the running object. If the other object |
| 16 | * is still interactive, that will be disconnected before the user is |
| 17 | * reconnected to that object. |
| 18 | * |
| 19 | * If the user is not in PASSWD, a new entry with level 0 is created. |
| 20 | * All PASSWD writing is done in secure/master.c. |
| 21 | * |
| 22 | */ |
| 23 | #pragma strict_types |
| 24 | #pragma no_shadow |
| 25 | #pragma no_inherit |
| 26 | #pragma verbose_errors |
| 27 | #pragma combine_strings |
| 28 | //#pragma pedantic |
| 29 | //#pragma range_check |
| 30 | #pragma warn_deprecated |
| 31 | |
| 32 | #include <config.h> |
| 33 | #include <properties.h> |
| 34 | #include <moving.h> |
| 35 | #include "/secure/wizlevels.h" |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 36 | |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 37 | #include <telnet.h> |
| 38 | #include <defines.h> |
| 39 | #include <input_to.h> |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 40 | #include <configuration.h> |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 41 | |
| 42 | inherit "/secure/mini_props.c"; |
| 43 | inherit "/secure/telnetneg.c"; |
| 44 | |
| 45 | #define SSL_GRRETING "REMOTE_HOST=" |
| 46 | #define PROXIES ({"127.0.0.1","87.79.24.60"}) |
| 47 | #define GUESTMASTER "/secure/guestmaster" |
| 48 | |
| 49 | #ifndef DEBUG |
| 50 | #define DEBUG(x) if(find_player("tiamak")) tell_object(find_player("tiamak"),x) |
| 51 | #define DEBUGM(x) if(find_player("muadib")) tell_object(find_player("muadib"),x) |
| 52 | #endif |
| 53 | |
| 54 | /* Variables of the secure save file */ |
| 55 | int level, loginfails, creation_date; |
| 56 | string password, name, shell, ep, ek, mq; |
| 57 | string ektips; |
| 58 | string fptips; |
| 59 | string *domains, *guilds, *uidstotakecare; |
| 60 | |
| 61 | static int invis, neu; |
| 62 | static string loginname; |
| 63 | static string cap_name; |
| 64 | static string *userentry; |
| 65 | static string banish; |
| 66 | static mixed *races; |
| 67 | static int newbie; |
| 68 | static string realip; |
| 69 | |
| 70 | // Prototypes |
| 71 | static void SendTelopts(); |
| 72 | public nomask string loginname(); |
| 73 | // the following 4 lfuns deal with real logins |
| 74 | public nomask int logon(); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 75 | static void logon2( string str ); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 76 | static int load_player_object( int guestflag ); |
| 77 | static void load_player_ob_2( string obname, int guestflag ); |
| 78 | static int check_illegal( string str ); |
| 79 | static int valid_name( string str ); |
| 80 | static int new_password( string str ); |
| 81 | static int again_password( string str ); |
| 82 | static int check_password( string str ); |
| 83 | static void select_race(); |
| 84 | static void ask_race_question(); |
| 85 | static void get_race_answer( string str ); |
| 86 | |
| 87 | protected void create(); |
| 88 | public string short(); |
| 89 | public string query_real_name(); |
| 90 | public nomask int query_prevent_shadow(); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 91 | public int remove(); |
| 92 | // the following 3 lfuns deal with dummy player creation |
| 93 | public mixed new_logon( string str); |
| 94 | static mixed new_load_player_object(); |
| 95 | static mixed new_load_player_ob_2( string obname ); |
| 96 | static void ask_mud_played_question(); |
| 97 | static void get_mud_played_answer(string str); |
| 98 | |
| 99 | |
| 100 | public nomask string loginname() |
| 101 | { |
| 102 | return loginname ? loginname : ""; |
| 103 | } |
| 104 | |
| 105 | |
| 106 | public int remove() |
| 107 | { |
| 108 | destruct( this_object() ); |
| 109 | return 1; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | static int check_too_many_logons() |
| 114 | { |
| 115 | object *u; |
| 116 | string ip; |
| 117 | |
| 118 | ip = query_ip_number(this_object()); |
| 119 | // users() nehmen, falls nicht-interaktive Clones von login.c existieren. |
| 120 | u = filter( users(), function status (object ob, string addr) { |
| Zesstra | 077f3c6 | 2016-09-30 21:24:05 +0200 | [diff] [blame] | 121 | return load_name(ob) == "/secure/login" |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 122 | && query_ip_number(ob) == addr; |
| 123 | }, ip ); |
| 124 | |
| Zesstra | cb45e3d | 2016-09-30 20:13:31 +0200 | [diff] [blame] | 125 | if ( sizeof(u) > 2) { |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 126 | write( "\nEs laufen schon zu viele Anmeldungen von Deiner Adresse " |
| 127 | "aus.\nProbier es bitte in ein bis zwei Minuten noch " |
| 128 | "einmal.\n" ); |
| 129 | |
| Zesstra | cb45e3d | 2016-09-30 20:13:31 +0200 | [diff] [blame] | 130 | log_file( "LOGIN_DENY", sprintf( "%s: >2 Logons von %-15s (%s)\n", |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 131 | ctime(time())[4..15], |
| 132 | query_ip_number(this_object()), |
| 133 | query_ip_name(this_object()) ) ); |
| 134 | return 1; |
| 135 | } |
| 136 | else |
| 137 | return 0; |
| 138 | } |
| 139 | |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 140 | // Callback when a TLS connection negotiation was finished. This handler is |
| 141 | // called for negotiations startet by the telnet option START_TLS. |
| 142 | protected void tls_init_callback(int handshake_result) |
| 143 | { |
| 144 | if (handshake_result < 0) |
| 145 | { |
| 146 | // Fehler im Vebindungsaufbau |
| 147 | write(break_string(sprintf( |
| 148 | "Can't establish a TLS/SSL encrypted connection: %s." |
| 149 | "Disconnecting now. If this error persists, please " |
| 150 | "disable the usage of TLS or STARTTLS in your client.", |
| 151 | tls_error(handshake_result)),78)); |
| 152 | // Disconnect |
| 153 | destruct(this_object()); |
| 154 | return; |
| 155 | } |
| 156 | // In this case, we will treat the newly negotiated TLS connection as as new |
| 157 | // connection and just start over again by calling logon(). And re-enable |
| 158 | // the telnet machine of the driver of course. |
| 159 | configure_interactive(this_object(), IC_TELNET_ENABLED, 1); |
| 160 | logon(); |
| 161 | } |
| 162 | |
| 163 | // Called from the telnetneg handler for TELOPT_STARTTLS to initiate the TLS |
| 164 | // connection negotiation. |
| 165 | protected void init_tls() |
| 166 | { |
| 167 | ::init_tls(); |
| 168 | configure_interactive(this_object(), IC_TELNET_ENABLED, 0); |
| 169 | tls_init_connection(this_object(), #'tls_init_callback); |
| 170 | } |
| 171 | |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 172 | /* |
| 173 | * This is the function that gets called by /secure/master for every user |
| 174 | */ |
| 175 | public nomask int logon() |
| 176 | { |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 177 | set_next_reset(300); // Timeout fuer Loginverfahren |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 178 | loginname = "logon"; |
| 179 | newbie=0; |
| Zesstra | ca50203 | 2020-02-05 19:56:09 +0100 | [diff] [blame] | 180 | realip=0; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 181 | |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 182 | SendTelopts(); |
| 183 | // In theory, we should not send anything if SendTelops() offers |
| 184 | // TELOPT_STARTTLS. However, some clients to not answer unknown telnet |
| 185 | // options and it would introduce a delay in any case. Therefore we send |
| 186 | // the welcome message anway, unless we received a WILL from the Client. |
| 187 | |
| 188 | // Es wird ein Lookup gemacht, ob die Quelladresse ein Tor-Exitnode ist, |
| 189 | // der erlaubt, zu uns zu kommunizieren. Das Lookup ist asynchron und |
| 190 | // braucht eine Weile, wenn das Ergebnis noch nicht gecacht ist. |
| 191 | // An dieser Stelle wird das Ergebnis nicht ausgewertet. Achja, wie |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 192 | // machen das natuerlich nicht fuer die IP vom Mudrechner... |
| 193 | if (query_ip_number(this_object()) != "87.79.24.60") |
| 194 | { |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 195 | ({int})"/p/daemon/dnslookup"->check_tor(query_ip_number(this_object()), |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 196 | query_mud_port()); |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 197 | ({int})"/p/daemon/dnslookup"->check_dnsbl(query_ip_number(this_object())); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 198 | } |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 199 | |
| 200 | // ggf. muss TLS (initiiert durch STARTTLS) noch ausverhandelt werden. |
| 201 | if (check_tls_negotiation()) |
| 202 | return 1; // Verbindung behalten |
| 203 | |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 204 | printf("HTTP/1.0 302 Found\n" |
| 205 | "Location: http://mg.mud.de/\n\n" |
| 206 | "NetCologne, Koeln, Germany. Local time: %s\n\n" |
| 207 | MUDNAME" LDmud, NATIVE mode, driver version %s\n\n", |
| 208 | strftime("%c"), __VERSION__); |
| 209 | |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 210 | if ( check_too_many_logons() ){ |
| 211 | destruct(this_object()); |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | // ist die Verbindung schon wieder weg? |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 216 | if (!objectp(this_object()) || !interactive(this_object())) |
| 217 | return 0; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 218 | |
| Zesstra | e037c1d | 2020-02-02 22:02:14 +0100 | [diff] [blame] | 219 | |
| 220 | cat( "/etc/WELCOME" ); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 221 | input_to( "logon2", INPUT_PROMPT, |
| 222 | "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? "); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 223 | return 1; |
| 224 | } |
| 225 | |
| 226 | |
| 227 | static int check_too_many_from_same_ip() |
| 228 | { |
| 229 | object *u; |
| 230 | string ip; |
| 231 | |
| 232 | ip = query_ip_number(this_object()); |
| 233 | u = filter(users(), function status (object ob, string addr, int a) { |
| 234 | return query_ip_number(ob) == addr |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 235 | && ({int})ob->QueryProp(P_AGE) < a; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 236 | }, ip, 12*60*60); // 24h in heart_beats |
| 237 | |
| 238 | if ( sizeof(u) > 25 ){ |
| 239 | write( "\nDa anscheinend gerade jemand von Deiner Adresse aus " |
| 240 | "versucht, das \n"MUDNAME" mit neuen Charakteren zu " |
| 241 | "ueberschwemmen, werden momentan \nnur aeltere Charaktere " |
| 242 | "von dieser Adresse zugelassen.\nWenn Du meinst, dass es " |
| 243 | "sich um einen Fehler handelt, logg Dich bitte als \n" |
| 244 | "Gast ein und sprich einen Erzmagier oder Gott an.\n" ); |
| 245 | |
| 246 | log_file( "LOGIN_DENY", sprintf( "%s: >10 Spieler von %-15s (%s)\n", |
| 247 | ctime(time())[4..15], |
| 248 | query_ip_number(this_object()), |
| 249 | query_ip_name(this_object()) ) ); |
| 250 | |
| 251 | destruct(this_object()); |
| 252 | return 1; |
| 253 | } |
| 254 | else |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | |
| 259 | static int check_illegal( string str ) |
| 260 | { |
| 261 | string res; |
| 262 | |
| Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 263 | res = ({string})master()->QuerySBanished(query_ip_number(this_object())); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 264 | if (!res) |
| 265 | { |
| 266 | // check connection from Tor exit node |
| Zesstra | ca50203 | 2020-02-05 19:56:09 +0100 | [diff] [blame] | 267 | string eff_ip = (sizeof(realip) ? realip |
| 268 | : query_ip_number(this_object())); |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 269 | if (({int})"/p/daemon/dnslookup"->check_tor(eff_ip, query_mud_port()) |
| 270 | || ({int})"/p/daemon/dnslookup"->check_dnsbl(eff_ip)) |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 271 | res = |
| 272 | "\nSorry, von Deiner Adresse kamen ein paar Idioten, die " |
| 273 | "ausschliesslich\nAerger machen wollten. Deshalb haben wir " |
| 274 | "die Moeglichkeit,\neinfach neue Charaktere " |
| 275 | "anzulegen, fuer diese Adresse gesperrt.\n\n" |
| 276 | "Falls Du bei uns spielen moechtest, schicke bitte eine Email " |
| 277 | "an\n\n mud@mg.mud.de\n\n" |
| 278 | "mit der Bitte, einen Charakter fuer Dich anzulegen.\n" ; |
| 279 | } |
| 280 | |
| 281 | if ( res ) |
| 282 | { |
| 283 | write( res ); |
| 284 | log_file( "LOGIN_DENY", sprintf( "%s: %-11s %-15s (%s)\n", |
| 285 | ctime(time())[4..15], str, |
| 286 | query_ip_number(this_object()), |
| 287 | query_ip_name(this_object()) ) ); |
| 288 | remove(); |
| 289 | return 1; |
| 290 | } |
| 291 | |
| 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | |
| 296 | /* |
| 297 | * Check that a player name is valid. Only allow |
| 298 | * lowercase letters. |
| 299 | */ |
| 300 | static int valid_name( string str ) |
| 301 | { |
| 302 | int i; |
| 303 | |
| 304 | if ( str == "logon" ){ |
| 305 | write( "Der Name wuerde nur Verwirrung stiften.\n" ); |
| 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | i = sizeof(str); |
| 310 | |
| 311 | if ( i > 11 ){ |
| 312 | write( "Dein Name ist zu lang, nimm bitte einen anderen.\n" ); |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | for ( ; i--; ) |
| 317 | if ( str[i] < 'a' || str[i] > 'z' ) { |
| 318 | write( "Unerlaubtes Zeichen '" + str[i..i] + "' im Namen: " + str |
| 319 | + "\n" ); |
| 320 | write( "Benutze bitte nur Buchstaben ohne Umlaute.\n" ); |
| 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | return 1; |
| 325 | } |
| 326 | |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 327 | static void logon2( string str ) |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 328 | { |
| 329 | int i, arg; |
| 330 | mixed txt; |
| 331 | |
| Zesstra | 4c418f9 | 2020-02-03 20:14:35 +0100 | [diff] [blame] | 332 | // ggf. muss TLS (initiiert durch STARTTLS) noch ausverhandelt werden. |
| 333 | if (check_tls_negotiation()) |
| 334 | return; |
| 335 | |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 336 | if ( !str || str == "" ){ |
| 337 | write( "Abbruch!\n" ); |
| 338 | destruct( this_object() ); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 339 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 340 | } |
| 341 | |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 342 | if(strstr(str,SSL_GRRETING)==0) |
| 343 | { |
| 344 | if( member(PROXIES,query_ip_number(this_object()))>-1 ) |
| 345 | { |
| 346 | realip=str[sizeof(SSL_GRRETING)..]; |
| 347 | } // andere IPs werden einfach ignoriert. -> log/PROXY.REQ ? |
| 348 | // ggf. Lookup fuer Torexits anstossen. |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 349 | ({int})"/p/daemon/dnslookup"->check_tor(realip,query_mud_port()); |
| 350 | ({int})"/p/daemon/dnslookup"->check_dnsbl(realip); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 351 | |
| 352 | input_to( "logon2", INPUT_PROMPT, |
| 353 | "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 354 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | if ( loginname != "logon" ) { |
| 358 | log_file( "ILLEGAL", sprintf( "%s Illegal patch of login: " |
| 359 | "loginname = %O\n", |
| 360 | dtime(time()), loginname ) ); |
| 361 | destruct( this_object() ); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 362 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | str = lower_case(str); |
| 366 | cap_name = capitalize(str); |
| 367 | |
| 368 | if ( str == "neu" && !neu ){ |
| 369 | cat( "/etc/WELCOME_NEW" ); |
| 370 | neu = 1; |
| 371 | input_to( "logon2", INPUT_PROMPT, "Name: "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 372 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | if ( !valid_name(str) ){ |
| 376 | string pr; |
| 377 | if ( !neu ) |
| 378 | pr= "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? "; |
| 379 | else |
| 380 | pr= "Bitte gib Dir einen anderen Namen: "; |
| 381 | |
| 382 | input_to( "logon2", INPUT_PROMPT, pr ); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 383 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | if ( sscanf( str, "gast%d", arg ) == 1 ){ |
| 387 | write( "Du meinst wohl 'Gast' ...\n" ); |
| 388 | str = "gast"; |
| 389 | } |
| 390 | |
| 391 | loginname = str; |
| 392 | |
| 393 | /* read the secure save file to see if character already exists */ |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 394 | string ssavef=({string})master()->secure_savefile(loginname); |
| Zesstra | 313eee9 | 2017-01-31 14:55:08 +0100 | [diff] [blame] | 395 | if ( loginname != "gast" |
| 396 | && (!ssavef || !sizeof(ssavef) || !restore_object(ssavef) )) |
| Zesstra | e43dd60 | 2017-01-31 10:48:10 +0100 | [diff] [blame] | 397 | { |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 398 | object *user; |
| 399 | |
| 400 | if ( !neu ) |
| 401 | { |
| 402 | write( "Es existiert kein Charakter mit diesem Namen.\n" ); |
| 403 | write( "Falls Du einen neuen Charakter erschaffen moechtest, " |
| 404 | "tippe bitte \"neu\" ein.\n" ); |
| 405 | |
| 406 | loginname = "logon"; |
| 407 | input_to( "logon2", INPUT_PROMPT, |
| 408 | "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 409 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | for ( i = sizeof(user = users() - ({ 0, this_object() })); i--; ) |
| 413 | if ( object_name(user[i])[0..12] == "/secure/login" && |
| Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 414 | (({string})user[i]->loginname()) == loginname ){ |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 415 | write( "Eine Anmeldung fuer diesen Namen laeuft bereits.\n" ); |
| 416 | destruct( this_object() ); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 417 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | // Site-Banish checken |
| 421 | if ( check_illegal(loginname)) |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 422 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 423 | |
| 424 | if ( check_too_many_from_same_ip() ) |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 425 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 426 | |
| 427 | /* new character */ |
| 428 | if ( sizeof(loginname) < 3 ){ |
| 429 | write( "Der Name ist zu kurz.\n" ); |
| 430 | loginname = "logon"; |
| 431 | input_to( "logon2", INPUT_PROMPT, |
| 432 | "Versuch einen anderen Namen: "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 433 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | |
| Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 437 | if ( (txt = ({string})master()->QueryBanished(loginname)) ){ |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 438 | if ( txt != "Dieser Name ist gesperrt." ) |
| 439 | txt = sprintf("Hoppla - dieser Name ist reserviert oder gesperrt " |
| 440 | "(\"gebanisht\")!\nGrund: %s\n",txt); |
| 441 | else |
| 442 | txt = "Hoppla - dieser Name ist reserviert oder gesperrt " |
| 443 | "(\"gebanisht\")!\n"; |
| 444 | write(txt); |
| 445 | loginname = "logon"; |
| 446 | input_to( "logon2", INPUT_PROMPT, |
| 447 | "Bitte gib Dir einen anderen Namen: "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 448 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | /* Initialize the new secure savefile */ |
| 452 | name = loginname; |
| 453 | password = ""; |
| 454 | level = 0; |
| 455 | domains = ({ }); |
| 456 | guilds = ({ }); |
| 457 | shell = ""; |
| 458 | ep = ""; |
| 459 | ek = ""; |
| 460 | mq = ""; |
| 461 | ektips=""; |
| 462 | fptips=""; |
| 463 | creation_date = time(); |
| 464 | |
| 465 | input_to( "new_password", INPUT_NOECHO|INPUT_PROMPT, |
| 466 | "Waehle ein Passwort: "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 467 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 468 | } |
| 469 | else { |
| 470 | if ( loginname == "gast" ){ |
| 471 | if ( check_illegal(loginname) ) |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 472 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 473 | |
| 474 | load_player_object(1); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 475 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | if ( neu ){ |
| 479 | write( "Es existiert bereits ein Charakter dieses Namens.\n" ); |
| 480 | loginname = "logon"; |
| 481 | input_to( "logon2", INPUT_PROMPT, |
| 482 | "Gib Dir einen anderen Namen: "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 483 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 484 | } |
| 485 | |
| Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 486 | if ( ({int})master()->check_late_player(loginname) ) |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 487 | { |
| 488 | write( "Dieser Spieler hat uns leider fuer immer verlassen.\n" ); |
| 489 | loginname = "logon"; |
| 490 | input_to( "logon2", INPUT_PROMPT, |
| 491 | "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 492 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 493 | } |
| 494 | |
| Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 495 | if ( txt = ({string})master()->QueryTBanished(loginname) ){ |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 496 | write( txt ); |
| 497 | loginname = "logon"; |
| 498 | input_to( "logon2", INPUT_PROMPT, |
| 499 | "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 500 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | if ( creation_date > (time() - 30*24*60*60) |
| 504 | && check_too_many_from_same_ip() ) |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 505 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 506 | |
| 507 | write( "Schoen, dass Du wieder da bist, "+capitalize(loginname)+"!\n" ); |
| 508 | |
| 509 | if ( !stringp(password) || password == "" ) { |
| 510 | write( "Du hast KEIN PASSWORD!\n" ); |
| 511 | write( "Benutze den \"password\"-Befehl, um das zu aendern !\n" ); |
| 512 | load_player_object(0); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 513 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | input_to( "check_password", INPUT_NOECHO|INPUT_PROMPT, |
| 517 | "Passwort: "); |
| Zesstra | b75a89c | 2020-01-31 18:47:57 +0100 | [diff] [blame] | 518 | return; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | |
| 522 | |
| 523 | static int new_password( string str ) |
| 524 | { |
| 525 | write( "\n" ); |
| 526 | |
| 527 | if ( !str || str == "" ) |
| 528 | return remove(); |
| 529 | |
| 530 | password = str; |
| 531 | |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 532 | if ( !({int})master()->good_password( str, loginname ) ) { |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 533 | input_to( "new_password", INPUT_NOECHO|INPUT_PROMPT, |
| 534 | "Bitte gib ein Passwort an: "); |
| 535 | return 1; |
| 536 | } |
| 537 | |
| 538 | write( "\nZur Erinnerung: Es ist v e r b o t e n, andere Spieler " |
| 539 | "anzugreifen!\n" ); |
| 540 | write( "Das gilt auch fuer Froesche, bei denen \"Ein Frosch namens " |
| 541 | "XXXXX\" steht.\n\n" ); |
| 542 | input_to( "again_password", INPUT_NOECHO|INPUT_PROMPT, |
| 543 | "Passwort bitte nochmal eingeben: "); |
| 544 | return 1; |
| 545 | } |
| 546 | |
| 547 | static int again_password( string str ) |
| 548 | { |
| 549 | write( "\n" ); |
| 550 | |
| 551 | if ( str != password ){ |
| 552 | write( "Die Passwoerter stimmten nicht ueberein!\n" ); |
| 553 | destruct( this_object() ); |
| 554 | return 1; |
| 555 | } |
| 556 | |
| Zesstra | 28d72e5 | 2016-10-27 23:56:19 +0200 | [diff] [blame] | 557 | set_next_reset(600); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 558 | password = md5_crypt( password, 0 ); |
| 559 | save_object( SECURESAVEPATH + loginname[0..0] + "/" + loginname ); |
| 560 | master()->RemoveFromCache( loginname ); |
| 561 | |
| 562 | load_player_object(0); |
| 563 | return 1; |
| 564 | } |
| 565 | |
| 566 | static int check_password( string str ) |
| 567 | { |
| 568 | write( "\n" ); |
| 569 | |
| 570 | // Invis einloggen? |
| 571 | if (sizeof(str) > 1 && str[0] == '-') { |
| 572 | invis = 1; |
| 573 | str = str[1..]; |
| 574 | } |
| 575 | |
| 576 | // welcher Hash ists denn? |
| 577 | if (sizeof(password) > 13) { |
| 578 | // MD5-Hash |
| 579 | str = md5_crypt(str, password); |
| 580 | } |
| 581 | else if (sizeof(password) > 2) { |
| 582 | // Crypt-Hash |
| 583 | str = crypt(str, password[0..1]); |
| 584 | } |
| 585 | else { |
| 586 | // keiner von beiden Hashes -> ungueltiges PW |
| 587 | str = 0; |
| 588 | } |
| 589 | |
| 590 | if ( !stringp(str) || str != password ) { |
| 591 | // Hashes stimmen nicht ueberein -> und schluss... |
| 592 | write( "Falsches Passwort!\n"); |
| 593 | if ( loginfails > 2 ) |
| 594 | write(break_string( |
| 595 | "Solltest Du weiterhin Probleme mit dem Einloggen haben, kannst " |
| 596 | "Du Dein Passwort zuruecksetzen lassen, indem Du Dich als Gast " |
| 597 | "anmeldest und einen Erzmagier ansprichst, oder indem Du Dich " |
| Zesstra | 0559c66 | 2017-02-06 19:14:51 +0100 | [diff] [blame] | 598 | "mittels einer E-Mail an mud@mg.mud.de mit uns in Verbindung " |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 599 | "setzt.",78)); |
| 600 | |
| 601 | log_file( (level < 60 ? "LOGINFAIL" : "ARCH/LOGINFAIL"), |
| 602 | sprintf( "PASSWORD: %-11s %s, %-15s (%s)\n", |
| 603 | loginname, ctime(time())[4..15], |
| 604 | query_ip_number(this_object()), |
| 605 | query_ip_name(this_object()) ), 200000 ); |
| 606 | |
| 607 | loginfails++; |
| 608 | save_object( SECURESAVEPATH + loginname[0..0] + "/" + loginname ); |
| 609 | master()->RemoveFromCache( loginname ); |
| 610 | destruct( this_object() ); |
| 611 | return 1; |
| 612 | } |
| 613 | |
| 614 | if ( loginfails ) { |
| 615 | write( loginfails + " fehlgeschlagene" + (loginfails == 1 ? "r" : "") + |
| 616 | " Login-Versuch" + (loginfails == 1 ? "" : "e") + |
| 617 | " seit dem letzten erfolgreichen Login.\n" ); |
| 618 | loginfails = 0; |
| 619 | } |
| 620 | |
| 621 | save_object( SECURESAVEPATH + loginname[0..0] + "/" + loginname ); |
| 622 | master()->RemoveFromCache( loginname ); |
| 623 | |
| 624 | load_player_object(0); |
| 625 | return 1; |
| 626 | } |
| 627 | |
| 628 | |
| 629 | static void select_race() |
| 630 | { |
| 631 | int i; |
| Zesstra | 7e35366 | 2019-11-27 19:52:41 +0100 | [diff] [blame] | 632 | string race; |
| 633 | int selectable; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 634 | |
| 635 | races = get_dir( "/std/shells/*.c" ); |
| 636 | |
| 637 | // Mensch soll immer als erstes in der Auswahlliste stehen. |
| 638 | if (member(races,"human.c")!=-1) |
| 639 | races=({"human.c"})+(races-({"human.c"})); |
| 640 | |
| 641 | for ( i = sizeof(races); i--; ){ |
| 642 | races[i] = "/std/shells/" + races[i][0..<3]; |
| Zesstra | 7e35366 | 2019-11-27 19:52:41 +0100 | [diff] [blame] | 643 | selectable = 0; |
| 644 | race = 0; |
| 645 | if ( catch(selectable = ({int})call_other( races[i], |
| 646 | "QueryAllowSelect" ); publish) |
| 647 | || !selectable) |
| 648 | selectable = 0; |
| 649 | else if ( catch(race = ({string})call_other(races[i], |
| 650 | "QueryProp", P_RACE );publish) ) |
| 651 | race = 0; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 652 | |
| Zesstra | 7e35366 | 2019-11-27 19:52:41 +0100 | [diff] [blame] | 653 | if ( !selectable || !sizeof(race) ) |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 654 | races[i..i] = ({}); |
| 655 | else |
| Zesstra | 7e35366 | 2019-11-27 19:52:41 +0100 | [diff] [blame] | 656 | races[i] = ({ races[i], race }); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | if ( sizeof(races) == 1 ){ |
| 660 | write( "Es gibt nur eine Rasse, Du hast also keine Wahl.\n" ); |
| 661 | |
| 662 | shell = races[0][0]; |
| 663 | master()->set_player_object( loginname, shell ); |
| 664 | |
| 665 | return load_player_ob_2( shell, 0 ); |
| 666 | } |
| 667 | |
| 668 | return ask_mud_played_question(); |
| 669 | } |
| 670 | |
| 671 | static void ask_mud_played_question() |
| 672 | { |
| 673 | write(break_string( |
| 674 | "\nWenn Du ein absoluter Neuling in diesem Spiel bist moechten " |
| 675 | "wir Dir mit einigen Tips zu Beginn beiseite stehen.\n\n",78, |
| 676 | 0,BS_LEAVE_MY_LFS)); |
| 677 | input_to( "get_mud_played_answer", INPUT_PROMPT, |
| 678 | "Hast Du schon einmal in einem MUD gespielt? (ja,nein): "); |
| 679 | return; |
| 680 | } |
| 681 | |
| 682 | static void ask_race_question() |
| 683 | { |
| 684 | int i, j; |
| 685 | |
| 686 | write( break_string( "Du musst Dich jetzt entscheiden, welcher Rasse Du " |
| 687 | "in dieser Welt angehoeren moechtest. Alle Rassen " |
| 688 | "haben verschiedene Vor- und Nachteile, insgesamt " |
| 689 | "aber gleich gute Chancen. Auch das Startgebiet " |
| 690 | "haengt von der ausgewaehlten Rasse ab. Im " |
| 691 | "Normalfall kann die Rasse nicht mehr gewechselt " |
| 692 | "werden, nachdem sie einmal ausgewaehlt wurde. " |
| 693 | "Ueberlege Dir Deine Entscheidung also gut. Derzeit " |
| 694 | "stehen folgende Rassen zur Auswahl:\n\n", 78 ) ); |
| 695 | |
| 696 | for ( i = 0, j = sizeof(races); i < j; i++ ) |
| 697 | printf( "% 2d. %-30s %s", i+1, capitalize(races[i][1]), |
| 698 | (i % 2 ? "\n" : "| ") ); |
| 699 | |
| 700 | if ( sizeof(races) % 2 ) |
| 701 | write( "\n" ); |
| 702 | |
| 703 | write( break_string( "\nDurch Eingabe einer Ziffer waehlst Du die Rasse " |
| 704 | "aus, durch Eingabe eines \"\?\" gefolgt von einer " |
| 705 | "Ziffer erhaeltst Du naehere Informationen ueber " |
| 706 | "eine Rasse. Ein \"\?\" allein wiederholt diese " |
| 707 | "Liste.", 78, 0, 1 ) ); |
| 708 | |
| 709 | if (newbie) |
| 710 | { |
| 711 | write(break_string("\nAls Neuling solltest Du Dich NICHT fuer " |
| 712 | "die Dunkelelfen entscheiden. Diese " |
| 713 | "Rasse hat einige Probleme im Umgang " |
| 714 | "mit den anderen Rassen und mit dem " |
| 715 | "Sonnenlicht.",78,0,BS_LEAVE_MY_LFS)); |
| 716 | } |
| 717 | |
| 718 | input_to( "get_race_answer", INPUT_PROMPT, |
| 719 | "\nWas willst Du tun: "); |
| 720 | return; |
| 721 | } |
| 722 | |
| 723 | |
| 724 | static void get_race_answer( string str ) |
| 725 | { |
| 726 | int num; |
| 727 | |
| 728 | if ( str == "?" ) |
| 729 | return ask_race_question(); |
| 730 | |
| 731 | if ( sscanf( str, "?%d", num ) ){ |
| 732 | if ( num < 1 || num > sizeof(races) ){ |
| 733 | write( "Das geht nicht.\n\n"); |
| 734 | input_to( "get_race_answer", INPUT_PROMPT, |
| 735 | "Was willst Du tun: "); |
| 736 | return; |
| 737 | } |
| 738 | |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 739 | write( ({string})call_other( races[num - 1][0], "QueryProp", P_RACE_DESCRIPTION )); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 740 | input_to( "get_race_answer", INPUT_PROMPT, |
| 741 | "\nWas willst Du tun: "); |
| 742 | return; |
| 743 | } |
| 744 | |
| 745 | if ( sscanf( str, "%d", num ) && num >= 1 && num <= sizeof(races) ){ |
| 746 | write( "Ok, Du bist jetzt ein " |
| 747 | + capitalize(races[num-1][1]) + ".\n" ); |
| 748 | |
| 749 | shell = races[num-1][0]; |
| 750 | master()->set_player_object( loginname, shell ); |
| 751 | return load_player_ob_2( shell, 0 ); |
| 752 | } |
| 753 | |
| 754 | write("Wie bitte?\n\n" ); |
| 755 | input_to( "get_race_answer", INPUT_PROMPT, |
| 756 | "Was willst Du tun: "); |
| 757 | } |
| 758 | |
| 759 | static void get_mud_played_answer (string str) |
| 760 | { |
| 761 | if ( str == "ja" || str=="j") |
| 762 | { |
| 763 | newbie=0; |
| 764 | return ask_race_question(); |
| 765 | } |
| 766 | if ( str != "nein" && str!="n") |
| 767 | { |
| 768 | write("\n\nAntworte bitte mit ja oder nein.\n\n"); |
| 769 | |
| 770 | return ask_mud_played_question(); |
| 771 | } |
| 772 | newbie=1; |
| 773 | write("\n\nEine kleine Einfuehrung in das "MUDNAME" bekommst " |
| 774 | "Du auch hier:\n\n" |
| 775 | "http://mg.mud.de/newweb/hilfe/tutorial/inhalt.shtml\n\n"); |
| 776 | return ask_race_question(); |
| 777 | |
| 778 | } |
| 779 | |
| 780 | static int load_player_object( int guestflag ) |
| 781 | { |
| 782 | object ob; |
| 783 | string fname; |
| 784 | int was_interactive; |
| 785 | |
| 786 | if ( sizeof(users()) >= 195 && !IS_WIZARD(loginname) ){ |
| 787 | write( "Die maximale Spielerzahl wurde bereits erreicht!!!\n" |
| 788 | "Aus technischen Gruenden duerfen sich nur noch Magier " |
| 789 | "einloggen.\nVersuch es spaeter noch einmal ...\n" ); |
| 790 | destruct( this_object() ); |
| 791 | return 1; |
| 792 | } |
| 793 | else if ( sizeof(users()) >= 198 && !IS_ARCH(loginname) ){ |
| 794 | write( "Die maximale Spieler- und Magierzahl wurde bereits erreicht!!!" |
| 795 | "\nAus technischen Gruenden duerfen sich nur noch Erzmagier " |
| 796 | "einloggen.\nVersuch es spaeter noch einmal ...\n" ); |
| 797 | destruct( this_object() ); |
| 798 | return 1; |
| 799 | } |
| 800 | |
| 801 | if ( file_size("/etc/NOLOGIN")>=0 ) |
| 802 | { |
| 803 | if (file_size("/etc/NOLOGIN.info")>0) { |
| 804 | //NOLOGIN.info enthaelt evtl. weitergehende Informationen fuer |
| 805 | //Spieler, z.B. vorrauss. Wiederverfuegbarkeit. |
| 806 | write(break_string(read_file("/etc/NOLOGIN.info"),78,"", |
| 807 | BS_LEAVE_MY_LFS|BS_SINGLE_SPACE)); |
| 808 | } |
| 809 | else { |
| 810 | //sonst Standardmeldung ausgeben. |
| 811 | write ("\nAufgrund von technischen Problemen ist das Einloggen ins " |
| 812 | MUDNAME" zur \nZeit nicht moeglich. Bitte versuch es " |
| 813 | "spaeter noch einmal.\n\n"); |
| 814 | } |
| 815 | if ( IS_ARCH(loginname) || |
| 816 | member(explode(read_file("/etc/NOLOGIN")||"","\n"), |
| 817 | loginname)!=-1 ) |
| 818 | { |
| 819 | write("Im Moment koennen nur Erzmagier einloggen. Um Spieler " |
| 820 | "wieder ins Spiel zu lassen, muss die Datei '/etc/NOLOGIN' " |
| 821 | "geloescht werden.\n\n "); |
| 822 | } else { |
| 823 | destruct( this_object() ); |
| 824 | return 1; |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | if ( guestflag ){ |
| Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 829 | if ( catch(guestflag = ({int})GUESTMASTER->new_guest();publish) |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 830 | || !guestflag ){ |
| 831 | write( "Derzeit ist kein Gastlogin moeglich!\n" ); |
| 832 | destruct( this_object() ); |
| 833 | return 1; |
| 834 | } |
| 835 | |
| 836 | loginname = "gast" + guestflag; |
| 837 | cap_name = capitalize(loginname); |
| 838 | name = cap_name; |
| 839 | |
| 840 | if ( !(ob = find_player(loginname) || find_netdead(loginname)) ){ |
| 841 | object *user; |
| 842 | int i; |
| 843 | |
| 844 | // gegen Horden von Gast1 - wenn ein Gast noch am Prompt fuer |
| 845 | // das Geschlecht haengt, ist er ueber find_player() noch nicht |
| 846 | // zu finden ... |
| 847 | for ( i = sizeof(user = users() - ({ 0, this_object() })); i--; ) |
| 848 | if ( object_name(user[i])[0..11] == "/std/shells/" && |
| 849 | getuid(user[i]) == loginname ){ |
| 850 | ob = user[i]; |
| 851 | break; |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | if ( ob ){ |
| 856 | tell_object( ob, "Ein anderer Spieler moechte diesen Gastzugang " |
| 857 | "jetzt benutzen. Wenn es Dir hier\ngefallen hat, " |
| 858 | "ueberleg Dir doch einen Charakternamen und komm " |
| 859 | "unter diesem\nNamen wieder!\n" ); |
| 860 | destruct(ob); |
| 861 | } |
| 862 | |
| 863 | load_player_ob_2( "std/shells/human", guestflag ); |
| 864 | |
| 865 | return 1; |
| 866 | } |
| 867 | else { |
| 868 | /* Test if we are already playing */ |
| 869 | was_interactive = 0; |
| 870 | ob = find_player(loginname) || find_netdead(loginname); |
| 871 | |
| 872 | if (ob) { |
| 873 | write( "Du nimmst schon am Spiel teil!\n" ); |
| 874 | write( "Verwende Deine alte sterbliche Huelle ...\n" ); |
| 875 | |
| 876 | if ( interactive(ob) ) |
| 877 | { |
| 878 | /* The other object is still interactive; reconnect that "soul" |
| 879 | to a dummy object and destruct that, thus disconnecting the |
| 880 | other probably linkdead user. The real "body" is still |
| 881 | there for reconnecting by login.c */ |
| 882 | remove_interactive(ob); |
| 883 | was_interactive = 1; |
| 884 | } |
| 885 | // Wenn Invislogin, P_INVIS setzen. |
| 886 | if ( invis && IS_WIZARD(ob) ) |
| 887 | { |
| 888 | ob->SetProp( P_INVIS, ob->QueryProp(P_AGE) ); |
| 889 | tell_object( ob, "DU BIST UNSICHTBAR!\n" ); |
| 890 | } |
| 891 | /* Now reconnect to the old body */ |
| 892 | exec( ob, this_object() ); |
| 893 | ob->set_realip(realip); |
| Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 894 | if ( (({int})ob->QueryProp(P_LEVEL)) == -1 ) |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 895 | ob->start_player( cap_name ); |
| 896 | else |
| 897 | ob->Reconnect( was_interactive ); |
| 898 | |
| 899 | call_out( "remove", 2 ); |
| 900 | return 1; |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | /* read player object from passwd file */ |
| 905 | if ( stringp(shell) && shell != "" ) |
| 906 | load_player_ob_2 ( shell, 0 ); |
| 907 | else |
| 908 | select_race(); |
| 909 | |
| 910 | return 1; |
| 911 | } |
| 912 | |
| 913 | |
| 914 | static void load_player_ob_2( string obname, int guestflag ) |
| 915 | { |
| 916 | object blueprint; |
| 917 | string err, ob_name; |
| 918 | object ob, old_ob; |
| 919 | |
| 920 | if (!interactive()) { |
| 921 | destruct(this_object()); |
| 922 | return; |
| 923 | } |
| 924 | /* start player activity */ |
| Zesstra | e88826c | 2016-09-24 20:37:05 +0200 | [diff] [blame] | 925 | log_file( "syslog/shell/ENTER", sprintf( "%-11s %s, %-15s (%s).\n", |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 926 | capitalize(name), ctime(time())[4..15], |
| 927 | query_ip_number(this_object()), |
| 928 | query_ip_name(this_object()) ), 200000 ); |
| 929 | |
| 930 | seteuid(loginname); |
| 931 | |
| 932 | /* load the "real" player object */ |
| 933 | /* If some asshole has moved the blueprint */ |
| 934 | if ( objectp(blueprint = find_object(obname)) && environment(blueprint) ) |
| 935 | destruct(blueprint); |
| 936 | |
| 937 | if ( err = catch(ob = clone_object(obname);publish) ){ |
| 938 | log_file( "SHELLS", "Failed to load shell " + obname + ", " + |
| 939 | dtime(time()) + ", " + loginname + "\n" + err + "\n\n" ); |
| 940 | |
| 941 | write( "Konnte das passende Playerobjekt nicht laden. Lade " |
| 942 | "stattdessen\ndas Objekt Mensch. BITTE ERZMAGIER " |
| 943 | "BENACHRICHTIGEN !\n" ); |
| 944 | err = catch(ob = clone_object("/std/shells/human");publish); |
| 945 | } |
| 946 | |
| 947 | if ( !ob || err ) { |
| 948 | write( "Error on loading " + shell + "\nError = " + err + "\n" ); |
| 949 | destruct( this_object() ); |
| 950 | return; |
| 951 | } |
| 952 | |
| 953 | if ( guestflag ) |
| 954 | catch( GUESTMASTER->set_guest( guestflag, ob );publish ); |
| 955 | |
| 956 | ob_name = explode( object_name(ob), "#" )[0]; |
| 957 | |
| 958 | if ( sizeof(ob_name) > 11 && ob_name[0..11] == "/std/shells/" ) |
| 959 | ob_name = ob_name[11..]; |
| 960 | |
| 961 | ob_name = ob_name + ":" + loginname; |
| 962 | |
| 963 | if( !guestflag ) |
| 964 | { |
| 965 | if ( old_ob = find_object(ob_name) ) |
| 966 | { |
| 967 | catch(old_ob->remove();publish); |
| 968 | |
| 969 | if ( old_ob ) |
| 970 | destruct( old_ob ); |
| 971 | } |
| 972 | rename_object( ob, ob_name ); |
| 973 | ob->__reload_explore(); |
| 974 | } |
| 975 | exec( ob, this_object() ); |
| 976 | ob->set_realip(realip); |
| 977 | ob->start_player( cap_name ); |
| Zesstra | ab834bb | 2020-01-21 13:11:45 +0100 | [diff] [blame] | 978 | // Hinweis: Das Spielerobjekt holt sich in updates_after_restore() von hier |
| 979 | // den Status von invis und setzt ggf. P_INVIS, ausserdem den Status der |
| 980 | // Telnet Negotiations. |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 981 | |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 982 | // wenn der Spieler noch nicht im Mud gespielt hat, wird die aktuelle Zeit |
| 983 | // in die entsprechende Prop geschrieben. Die Prop ist transient und wird |
| 984 | // absichtlich nicht gespeichert. |
| 985 | if (newbie) |
| 986 | ob->SetProp("_lib_mud_newbie", creation_date); |
| 987 | |
| 988 | destruct( this_object() ); |
| 989 | } |
| 990 | |
| 991 | |
| 992 | /* |
| 993 | * With arg = 0 this function should only be entered once! |
| 994 | */ |
| 995 | protected void create() |
| 996 | { |
| 997 | loginname = "logon"; |
| 998 | creation_date = -1; |
| 999 | catch( load_object( "/secure/merlin");publish ); |
| 1000 | loginfails = 0; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1001 | if (clonep()) |
| 1002 | set_next_reset(900); |
| 1003 | else |
| 1004 | set_next_reset(-1); |
| 1005 | } |
| 1006 | |
| 1007 | void reset() |
| 1008 | { |
| 1009 | if (clonep()) |
| Zesstra | 28d72e5 | 2016-10-27 23:56:19 +0200 | [diff] [blame] | 1010 | { |
| 1011 | if (interactive(this_object())) |
| 1012 | tell_object(this_object(),"Time out!"); |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1013 | remove(); |
| Zesstra | 28d72e5 | 2016-10-27 23:56:19 +0200 | [diff] [blame] | 1014 | } |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | public string short() |
| 1018 | { |
| 1019 | return "<Einloggender Teilnehmer>.\n"; |
| 1020 | } |
| 1021 | |
| 1022 | |
| 1023 | public string query_real_name() |
| 1024 | { |
| 1025 | return "<logon>"; |
| 1026 | } |
| 1027 | |
| 1028 | |
| 1029 | public nomask int query_prevent_shadow() |
| 1030 | { |
| 1031 | return 1; |
| 1032 | } |
| 1033 | |
| 1034 | |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1035 | // Wird von simul_efuns benutzt, um nen dummy-Spielerobjekt zu erzeugen. Nicht |
| 1036 | // im Loginprozess involviert. |
| 1037 | public mixed new_logon( string str) |
| 1038 | { |
| 1039 | seteuid(getuid()); // sonst funkt ARCH_SECURITY nicht |
| 1040 | |
| 1041 | if ( !ARCH_SECURITY || process_call() ){ |
| 1042 | write( "Nur fuer Erzmagier erlaubt!\n" ); |
| 1043 | destruct( this_object() ); |
| 1044 | return -1; |
| 1045 | } |
| 1046 | |
| 1047 | if ( !str || str == "" ){ |
| 1048 | write( "Kein Name angegeben!\n" ); |
| 1049 | destruct( this_object() ); |
| 1050 | return 0; |
| 1051 | } |
| 1052 | |
| 1053 | str = lower_case(str); |
| 1054 | cap_name = capitalize(str); |
| 1055 | |
| 1056 | loginname = str; |
| 1057 | seteuid(ROOTID); |
| 1058 | |
| 1059 | /* read the secure save file to see if character already exists */ |
| bugfix | d94d093 | 2020-04-08 11:27:13 +0200 | [diff] [blame] | 1060 | if ( !restore_object( ({string})master()->secure_savefile(loginname) ) ){ |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1061 | write( "Kein solcher Spieler!\n" ); |
| 1062 | destruct( this_object() ); |
| 1063 | return 0; |
| 1064 | } |
| 1065 | else { |
| 1066 | write( "Ok, der Spieler " + capitalize(str) + " existiert!\n" ); |
| 1067 | return new_load_player_object(); |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | // Wird von simul_efuns benutzt, um nen dummy-Spielerobjekt zu erzeugen. Nicht |
| 1072 | // im Loginprozess involviert. |
| 1073 | static mixed new_load_player_object() |
| 1074 | { |
| 1075 | if ( find_player(loginname) || find_netdead(loginname) ){ |
| 1076 | write( "Der Spieler ist bereits online oder netztot!\n" ); |
| 1077 | destruct( this_object() ); |
| 1078 | return 2; |
| 1079 | } |
| 1080 | |
| 1081 | /* read player object from passwd file */ |
| 1082 | if ( stringp(shell) && shell != "" ) |
| 1083 | return new_load_player_ob_2( shell ); |
| 1084 | else { |
| 1085 | write( "Keine Shell angegeben!\n" ); |
| 1086 | destruct( this_object() ); |
| 1087 | return 0; |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | // Wird von simul_efuns benutzt, um nen dummy-Spielerobjekt zu erzeugen. Nicht |
| 1092 | // im Loginprozess involviert. |
| 1093 | static mixed new_load_player_ob_2( string obname ) |
| 1094 | { |
| 1095 | object blueprint; |
| 1096 | string err, ob_name; |
| 1097 | object ob, old_ob; |
| 1098 | |
| 1099 | seteuid(loginname); |
| 1100 | |
| 1101 | /* load the "real" player object */ |
| 1102 | /* If some asshole has moved the blueprint */ |
| 1103 | if ( objectp(blueprint = find_object(obname)) && environment(blueprint) ) |
| 1104 | destruct( blueprint ); |
| 1105 | |
| 1106 | err = catch(ob = clone_object(obname);publish); |
| 1107 | |
| 1108 | if ( err ){ |
| 1109 | log_file( "SHELLS", "Failed to load shell " + obname + ", " + |
| 1110 | dtime(time()) + ", " + loginname + "\n" + err + "\n\n" ); |
| 1111 | |
| 1112 | write( "Konnte das passende Playerobjekt nicht laden. " |
| 1113 | "Lade stattdessen\ndas Objekt Mensch!\n" ); |
| 1114 | |
| 1115 | err = catch(ob = clone_object( "std/shells/human" );publish ); |
| 1116 | } |
| 1117 | |
| 1118 | if ( !ob || err ){ |
| 1119 | write( "Error on loading " + shell + "\nError = " + err + "\n" ); |
| 1120 | destruct( this_object() ); |
| 1121 | return 0; |
| 1122 | } |
| 1123 | |
| 1124 | ob_name = explode( object_name(ob), "#" )[0]; |
| 1125 | |
| 1126 | if ( sizeof(ob_name) > 11 && ob_name[0..11] == "/std/shells/" ) |
| 1127 | ob_name = ob_name[11..]; |
| 1128 | |
| 1129 | ob_name = ob_name + ":" + loginname; |
| 1130 | |
| 1131 | if ( old_ob = find_object(ob_name) ){ |
| 1132 | catch( old_ob->remove(); publish ); |
| 1133 | |
| 1134 | if ( old_ob ) |
| 1135 | destruct( old_ob ); |
| 1136 | } |
| 1137 | |
| 1138 | rename_object( ob, ob_name ); |
| 1139 | ob->__reload_explore(); |
| 1140 | ob->set_realip(realip); |
| 1141 | ob->start_player(cap_name); |
| 1142 | ob->SetProp( "creation_date", creation_date ); |
| 1143 | ob->Set( "creation_date", SAVE|SECURED|PROTECTED, F_MODE_AS ); |
| 1144 | |
| 1145 | ob->move( "/room/nowhere", M_NOCHECK ); |
| 1146 | set_object_heart_beat( ob, 0 ); |
| 1147 | destruct( this_object() ); |
| 1148 | |
| 1149 | return ob; |
| 1150 | } |
| 1151 | |
| Zesstra | ca50203 | 2020-02-05 19:56:09 +0100 | [diff] [blame] | 1152 | public string query_realip() |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1153 | { |
| Zesstra | ca50203 | 2020-02-05 19:56:09 +0100 | [diff] [blame] | 1154 | return realip ? realip : 0; |
| MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | int query_invis() |
| 1158 | { |
| 1159 | return invis; |
| 1160 | } |
| 1161 | |