Guest User

Untitled

a guest
Aug 21st, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 30.99 KB | None | 0 0
  1. /*    /secure/lib/connect.c
  2.  *    from the Dead Souls Object Library
  3.  *    the object a user connects to before determining their real body
  4.  *    created by Descartes of Borg 951103
  5.  *    Version: @(#) connect.c 1.2@(#)
  6.  *    Last Modified: 96/05/28
  7.  */
  8.  
  9. #include <lib.h>
  10. #include ROOMS_H
  11. #include <news.h>
  12. #include <flags.h>
  13. #include <cfg.h>
  14. #include <daemons.h>
  15. #include <message_class.h>
  16. #include "include/connect.h"
  17.  
  18. #define CUSTOM_FORMAT 0
  19. #define REAL_NAME 0
  20.  
  21. #ifndef __ANSI_SUBSTITUTE__
  22. #define __ANSI_SUBSTITUTE__ 0x1e
  23. #endif
  24.  
  25. inherit LIB_PAGER;
  26. #include <mssp.h>
  27.  
  28. static private int CrackCount, NetDead, MaxPlayers, blindmode;
  29. static private string name, Name, Terminal, raza, TrueName, trabajo, extra;
  30. static private string Passwort, Gendre, CapNamen, E_Mail, my_ip, client_ip;
  31. static private object Player, pile;
  32. static private mapping LastError, UserVars;
  33. static private int *Screen;
  34. static private int rescue, yescre, anyterm;
  35. static private string *ip_permitted = ({}), instname, telopt_user;
  36. static private string array anyterms = ({"97.107.133.86", "127.0.0.1"});
  37.  
  38. //Change this to 0 to disable color codes in /news/welcome
  39. //then update the connect.c file.
  40. static private int AllowColorSplash = 1;
  41.  
  42. //Change this to 1 to change your welcome screen to /news/moved
  43. //and to disable the standard login prompts.
  44. static private int Moved = 0;
  45.  
  46. int eventCheckPending(string str);
  47. void eventCompleteChar();
  48. void InputCre(string str);
  49. static void cmdPickClass(string args);
  50. static void cmdListClasses();
  51. static void cmdHelpClass(string args);
  52. static void InputClass(string str);
  53. static void eventSelectClass();
  54.  
  55. int CheckIp(){
  56.     int ips = 0;
  57.     string tmp_ip;
  58.     if(!SAME_IP_MAX) return 1;
  59.     tmp_ip = query_ip_number();
  60.     if(telopt_user && telopt_user != my_ip) tmp_ip = telopt_user;
  61.     if(!ip_permitted) ip_permitted = ({});
  62.     ip_permitted += PLAYERS_D->GetAdminIPs();
  63.     ip_permitted = singular_array(ip_permitted);
  64.     if(member_array(tmp_ip, ip_permitted) != -1) return 1;
  65.     foreach(object jugador in users()){
  66.         if(query_ip_number(jugador) == tmp_ip) ips++;
  67.     }
  68.     if(ips >= SAME_IP_MAX) return 0;
  69.     return 1;
  70. }
  71.  
  72. static void create(int binary) {
  73.     extra = "";
  74.     UserVars = ([]);
  75.     if(query_windows()){
  76.         MaxPlayers = 50;
  77.     }
  78.     else {
  79. #ifdef __ULIMIT__
  80.         MaxPlayers = (__ULIMIT__ - 10);
  81. #else
  82. #if __FD_SETSIZE__
  83.         if(!MaxPlayers || MaxPlayers > __FD_SETSIZE__){
  84.             MaxPlayers = (__FD_SETSIZE__ - 10);
  85.         }
  86. #endif
  87. #endif
  88.     }
  89.     if(grepp(__ARCH__, "Solaris")){
  90. #ifndef __M64__
  91.         //Solaris has a problem with fd's over 256 in
  92.         //32-bit applications.
  93.         MaxPlayers = 200;
  94. #endif
  95.     }
  96.     if(!MaxPlayers) MaxPlayers = 1000;
  97.     if(MAX_USERS) MaxPlayers = MAX_USERS;
  98.     CrackCount = 0;
  99.     Name = "";
  100.     Player = 0;
  101.     NetDead = 0;
  102.     if(ENABLE_INSTANCES){
  103.         instname = INSTANCES_D->GetMyInstanceName();
  104.     }
  105.     ip_permitted = explode(read_file(CFG_IP_UNRESTRICT),"\n");
  106. }
  107.  
  108. varargs static void logon(mixed foo) {
  109.     string welcome = "Connected to "+mud_name()+", an LP mud";
  110.     if(sizeof(architecture())) welcome += " running on "+architecture()+".\n";
  111.     else welcome += ".\n";
  112.  
  113.     client_ip = query_ip_number();
  114.  
  115.     call_out((: eventTimeout :), LOGON_TIMEOUT);
  116.     if(mud_name() == "Dead Souls" || mud_name() == "Dead Souls Dev" ){
  117.         welcome += read_file(DS_WELCOME) || "Welcome to " + mud_name() + "!";
  118.     }
  119.     else {
  120.         string wfile;
  121.         if(instname && instname != "global"){
  122.             wfile = NEWS_WELCOME+"."+__PORT__;
  123.         }
  124.         if(!wfile || !file_exists(wfile)) wfile = NEWS_WELCOME;
  125.         welcome += read_file(wfile) || "Welcome to " + mud_name() + "!";
  126.     }
  127.     if(Moved){
  128.         string wfile;
  129.         if(instname && instname != "global"){
  130.             wfile = NEWS_MOVED+"."+__PORT__;
  131.         }
  132.         if(!wfile || !file_exists(wfile)) wfile = NEWS_MOVED;
  133.         welcome = read_file(wfile) || "Welcome to " + mud_name() + "!";
  134.     }
  135.     if(AllowColorSplash){
  136.         receive(terminal_colour(welcome,TERMINAL_D->query_term_info("ansi")));
  137.     }
  138.     else {
  139.         receive(welcome);
  140.     }    
  141.     if(!Moved){
  142.         receive("\n" + center("Driver: " + version() +
  143.                     "               Mudlib: "+
  144.                     mudlib() + " " + mudlib_version()) + "\n");
  145.         receive("\nWhat name do you wish? ");
  146.         input_to((: InputName :), I_NOESC);
  147.     }
  148. }
  149.  
  150. static void InputName(string namen, string kill_me) {
  151.     string temp_name, news;
  152.     mixed tmp;
  153.     int toomany;
  154.     name = namen;
  155.  
  156.     if(member_array(client_ip, anyterms) != -1){
  157.         if(telopt_user){
  158.             int bar = sscanf(telopt_user, "%*d.%*d.%*d.%*d");
  159.             if(bar == 4){
  160.                 client_ip = telopt_user;
  161.                 anyterm = 1;
  162.                 extra = " ["+my_ip+"]";
  163.             }
  164.         }
  165.     }
  166.  
  167.     if(!CheckIp()){
  168.         receive("\nToo many users from your site are currently logged on.\n");
  169.         receive("Please try again later.\n");
  170.         flush_messages();
  171.         Destruct();
  172.         return;
  173.     }
  174.  
  175.     if(sizeof(users()) >= MaxPlayers){
  176.         toomany = 1;
  177.     }
  178.  
  179.     if( !name || name == "" ) {
  180.         if( kill_me ) {
  181.             if(!Moved) receive("\nPerhaps try another time then?\n");
  182.             Destruct();
  183.             return;
  184.         }
  185.         else {
  186.             if(!Moved){
  187.                 receive("\nYou must enter a name in order to join!\n");
  188.                 receive("\nWhat name do you wish? ");
  189.             }
  190.             input_to((: InputName :), I_NOESC, "kill me");
  191.             return;
  192.         }
  193.     }
  194.     if(grepp(name, "MSSP-REQUEST")){
  195.         log_file("mssp",timestamp() + " " + my_ip + extra + "\n");
  196.         receive(mssp_reply());
  197.         flush_messages();
  198.         input_to((: InputName :), I_NOESC);
  199.         return;
  200.     }
  201.     if(sscanf(name,"%s_rescue",temp_name) == 1) {
  202.         name = temp_name;
  203.         rescue = 1;
  204.     }
  205.     Name = convert_name(name);
  206.     name = capitalize(name);
  207.     if( master()->is_locked() || toomany) {
  208.         if(toomany){
  209.             news = "Too many players logged in!";
  210.         }
  211.         else news = read_file(NEWS_LOCKED) || "No reason logged.";
  212.         receive("\n" + mud_name() + " is locked.  Reason:\n" + news + "\n");
  213.         if( CanLogin() ) receive("\n        >>> Access allowed <<<\n");
  214.         else {
  215.             receive("\n        >>> Access denied <<<\n");
  216.             flush_messages();
  217.             Destruct();
  218.             return;
  219.         }
  220.     }
  221.     if( !user_exists(Name) ) {
  222.         eventCreatePlayer(name);
  223.         return;
  224.     }
  225.     if( !(BANISH_D->eventConnect(Name, client_ip)) ) {
  226.         news = read_file(NEWS_BANISHED) || "You are not allowed here.\n";
  227.         receive("\n" + news + "\n");
  228.         Destruct();
  229.         return;
  230.     }
  231.     if( (tmp = CHARACTER_D->eventConnect(Name)) != 1 ) {
  232.         if( tmp ) receive(tmp + "\n");
  233.         else receive("One of your characters was recently logged in.\n"
  234.                 "You must wait a little longer before logging in.\n");
  235.         Destruct();
  236.         return;
  237.     }
  238.  
  239.     if( find_player(Name) ) NetDead = 1;
  240.  
  241.     if(Name != "guest"){
  242.         receive("Password: ");
  243.         input_to((: InputPassword :), I_NOECHO | I_NOESC, name);
  244.     }
  245.     else InputPassword("guest","Guest");
  246. }
  247.  
  248. static void InputPassword(string pass, string cap) {
  249.     string control;
  250.  
  251.     if(Name != "guest"){
  252.  
  253.         if( !pass || pass == "" ) {
  254.             receive("\nYou must enter a password.  Please try again later.\n");
  255.             Destruct();
  256.             return;
  257.         }
  258.         if(!cap || cap == "") {
  259.             receive("\nAn unusual error has occurred.  Please try again.\n");
  260.             Destruct();
  261.             return;
  262.         }
  263.  
  264.         control = PLAYERS_D->GetPlayerData(Name,"Password");
  265.         if( control != crypt(pass, control) ) {
  266.             receive("\nInvalid password.\n");
  267.             if( ++CrackCount > MAX_PASSWORD_TRIES ) {
  268.                 receive("\nNo more attempts allowed\n");
  269.                 unguarded( (: log_file("/secure/log/security",
  270.                   "Maximum password tries exceeded by " +
  271.                         Name + " from " + client_ip + extra + "\n") :) );
  272.                 filter(users(), (: archp :))->eventPrint("System %^MAGENTA%^"
  273.                         "<error>%^RESET%^ Maximum password "
  274.                         "attempts exceeded by " + cap +
  275.                         " from " + client_ip + ".\n",
  276.                         MSG_ERROR);
  277.                 Destruct();
  278.                 return;
  279.             }
  280.             receive("Password: ");
  281.             input_to( (: InputPassword :), I_NOECHO | I_NOESC, cap);
  282.             return;
  283.         }
  284.  
  285.         if(rescue) unguarded( (: wipe_inv(name) :) );
  286.     }
  287.  
  288.     Player = master()->player_object(Name);
  289.     if( !Player ) {
  290.         receive("\nIt seems some work is being done right now, try later.\n");
  291.         Destruct();
  292.         return;
  293.     }
  294.     PLAYERS_D->AddPlayerInfo(Player);
  295.     if( !Player->GetRace() || Player->GetRace() == "blob"
  296.             || Name == "guest" ) {
  297.         Player->SetRace("human");
  298.     }
  299.  
  300.     if( !NetDead ){
  301.         call_out( (: eventCheckPending, lower_case(Name) :), 3);
  302.         eventEnterGame();
  303.     }
  304.     else eventReEnterGame(cap);
  305. }
  306.  
  307. static void eventCreatePlayer(string cap) {
  308.     string tmpdir, lcname = lower_case(Name);
  309.     string *tmpfiles = ({});
  310.     if( !(BANISH_D->valid_name(lcname)) ) {
  311.         receive(capitalize(cap) + " is not a valid name.\n");
  312.         receive(mud_name() + " requires that all names meet the following "
  313.                 "requirements:\n");
  314.         receive("\tAll characters must be:\n");
  315.         receive("\t\tA-Z\n\t\ta-z\n\t\t'\n\t\t-\n");
  316.         receive("\tMinimum length: " + MIN_USER_NAME_LENGTH + "\n");
  317.         receive("\tMaximum length: " + MAX_USER_NAME_LENGTH + "\n");
  318.         receive("\nPlease enter a new name: \n");
  319.         input_to( (: InputName :), I_NOESC );
  320.         return;
  321.     }
  322.     tmpdir = DIR_PLAYERS "/" + lcname[0..0] + "/";
  323.     if(directory_exists(tmpdir)){
  324.         tmpfiles += get_dir(tmpdir);
  325.     }
  326.     tmpdir = DIR_CRES "/" + lcname[0..0] + "/";
  327.     if(directory_exists(tmpdir)){
  328.         tmpfiles += get_dir(tmpdir);
  329.     }
  330.     foreach(string tmpfile in tmpfiles){
  331.         if(!strsrch(tmpfile, lcname+".")){
  332.             receive("\nThat name is taken. Please choose a new one.\n");
  333.             input_to( (: InputName :), I_NOESC );
  334.             return;
  335.         }
  336.     }
  337.     if( !(BANISH_D->eventConnect(Name, client_ip)) ) {
  338.         string news;
  339.  
  340.         news = read_file(NEWS_REGISTER) || "No registration info.\n";
  341.         receive(news);
  342.         flush_messages();
  343.         Destruct();
  344.         return;
  345.     }
  346.     receive("Do you really wish to be known as " + cap + "? (y/n) \n");
  347.     input_to((: ConfirmName :), I_NOESC, cap);
  348. }
  349.  
  350. static BlindCheck(string ans, string cap){
  351.     if( !ans || ans == "" || lower_case(ans)[0..0] == "y" ) {
  352.         receive("\nOk, disabling default overhead map.\n");
  353.         blindmode = 1;
  354.     }
  355.     else receive("\Ok, allowing default overhead map behavior.\n");
  356.     log_file("new_players", Name + " (" + ctime(time()) + ")\n");
  357.     receive("\nCreate a password of at least 5 letters: \n");
  358.     input_to((: CreatePassword :), I_NOECHO | I_NOESC, cap);
  359. }
  360.  
  361. static void AgeCheck(string ans, string cap) {
  362.     if( !ans || ans == "" || lower_case(ans)[0..0] != "y" ) {
  363.         receive("\nSorry. You are not old enough to play here.\n");
  364.         Destruct();
  365.         return;
  366.     }
  367.     log_file("new_players", Name + " (" + ctime(time()) + ")\n");
  368.     unguarded( (: log_file("/secure/log/new_players", Name + " from "
  369.       + client_ip + extra + " (" + ctime(time()) + ")\n") :) );
  370.     receive("\nDo you use a screen reader for the visually impaired? (y/n)\n");
  371.     input_to((: BlindCheck :), I_NOESC, cap);
  372. }
  373.  
  374. static void ConfirmName(string ans, string cap) {
  375.     if( !ans || ans == "" || lower_case(ans)[0..0] != "y" ) {
  376.         receive("\nOk, then enter the name you really want: \n");
  377.         input_to( (: InputName :), I_NOESC );
  378.         return;
  379.     }
  380.     receive("\nAre you 13 years of age or older? (y/n) \n");
  381.     input_to((: AgeCheck :), I_NOESC, cap);
  382. }
  383.  
  384. static void eventReEnterGame(string cap) {
  385.     if( interactive(Player) ) {
  386.         receive("\nAn interactive copy of you currently exists.\n");
  387.         receive("Do you wish to take over this copy? (y/n) \n");
  388.         input_to((: ConfirmReconnect :), I_NOESC, cap);
  389.         return;
  390.     }
  391.     if( exec(Player, this_object()) ) {
  392.         if(rescue)
  393.             if(sizeof(deep_inventory(Player)))
  394.                 deep_inventory(Player)->eventMove(ROOM_FURNACE);
  395.         log_file("enter", cap + " (exec): " + ctime(time()) + "\n");
  396.         unguarded( (: log_file("/secure/log/enter", Name + " (exec): " +
  397.           ctime(time()) + " from " + client_ip + extra + "\n") :) );
  398.         Player->eventReconnect();
  399.         Player->RemoveProperty("afk");
  400.         if(!anyterm){
  401.             Player->CancelCharmode();
  402.             Player->SetProperty("reprompt", 0);
  403.             Player->SetTeloptIp(0);
  404.         }
  405.         else {
  406.             Player->SetTeloptIp(telopt_user);
  407.         }
  408.         if(creatorp(Player))
  409.             Player->AddChannel((CHAT_D->GetSystemChannels() - ({"muds"})));
  410.         SNOOP_D->ReportReconnect(Player->GetKeyName());
  411.         call_out( (: eventCheckPending, lower_case(Name) :), 3);
  412.     }
  413.     receive("\nProblem reconnecting.\n");
  414.     Destruct();
  415. }
  416.  
  417. static void ConfirmReconnect(string ans, string cap) {
  418.     object tmp;
  419.  
  420.     if( !stringp(ans) || ans == "" || lower_case(ans)[0..0] != "y" ) {
  421.         receive("\nThen please try again later!\n");
  422.         Destruct();
  423.         return;
  424.     }
  425.     if(rescue)
  426.         if(sizeof(deep_inventory(Player))) deep_inventory(Player)->eventMove(ROOM_FURNACE);
  427.     log_file("enter", cap + " (reconnect) ("+ctime(time())+")\n");
  428.     unguarded( (: log_file("/secure/log/enter", Name + " (reconnect) from "
  429.       + client_ip + extra + " (" + ctime(time()) + ")\n") :) );
  430.     exec(tmp = new(LIB_PLAYER), Player);
  431.     exec(Player, this_object());
  432.     destruct(tmp);
  433.     if(anyterm){
  434.         int oldlock = Player->GetProperty("screenlock");
  435.         Player->SetCharmode(1);
  436.         Player->SetProperty("reprompt",1);
  437.         Player->SetProperty("commandecho", "blue");
  438.         Player->SetProperty("keepalive", 5);
  439.         Player->SetProperty("screenlock", 0);
  440.         Player->SetScreen(80, 25);
  441.         Player->SetProperty("screenlock", oldlock);
  442.         Player->SetTeloptIp(telopt_user);
  443.     }
  444.     else {
  445.         Player->SetTeloptIp(0);
  446.     }
  447.     Player->eventPrint("\nAllowing login.\n", MSG_SYSTEM);
  448.     call_out( (: eventCheckPending, lower_case(Name) :), 3);
  449.     Destruct();
  450. }
  451.  
  452. static int CanLogin() {
  453.     string group;
  454.  
  455.     if( BANISH_D->GetGuest(Name) ) return 1;
  456.     foreach(group in LOCKED_ACCESS_ALLOWED)
  457.         if( member_group(Name, group) ) return 1;
  458.     return 0;
  459. }
  460.  
  461. static private void eventEnterGame() {
  462.     if(!exec(Player, this_object())) {
  463.         debug("problem connecting");
  464.         receive("\nProblem connecting.\n");
  465.         Player->eventDestruct();
  466.         destruct(this_object());
  467.         return;
  468.     }
  469.     if( Terminal ) Player->SetTerminal(Terminal);
  470.     if( Screen ) Player->SetScreen(Screen[0], Screen[1]);
  471.     Player->Setup();
  472.     if(creatorp(Player)){  
  473.         string profile = user_path(Player->GetKeyName())+".profile";
  474.         if(file_exists(profile)){
  475.             string q = "";
  476.             if(!MASTER_D->GetPerfOK()) q = "-q ";
  477.             Player->eventForce("source "+q+profile);
  478.         }
  479.     }
  480.     Player->RemoveProperty("afk");
  481.     if(creatorp(Player))
  482.         Player->AddChannel(((CHAT_D->GetSystemChannels()) - ({"muds"})));
  483.     SNOOP_D->CheckBot(Player->GetKeyName());
  484.     unguarded( (: log_file("/secure/log/enter", Name + " (enter): " +
  485.       ctime(time()) + " from " + client_ip + extra + "\n") :) );
  486.     if(anyterm){
  487.         int oldlock = Player->GetProperty("screenlock");
  488.         Player->SetCharmode(1);
  489.         Player->SetProperty("reprompt",1);
  490.         Player->SetProperty("commandecho", "blue");
  491.         Player->SetProperty("keepalive", 5);
  492.         Player->SetProperty("screenlock", 0);
  493.         Player->SetScreen(80, 25);
  494.         Player->SetProperty("screenlock", oldlock);
  495.         Player->SetTeloptIp(telopt_user);
  496.     }
  497.     else {
  498.         Player->SetTeloptIp(0);
  499.     }
  500.     call_out( (: destruct(this_object()) :), 10);
  501. }
  502.  
  503. static void CreatePassword(string pass, string cap) {
  504.     if( strlen(pass) < 3) {
  505.         receive("\nYour password must be at least 5 letters in length.\n");
  506.         receive("Please choose another password: ");
  507.         input_to( (: CreatePassword :), I_NOECHO | I_NOESC, cap);
  508.         return;
  509.     }
  510.     receive("\nPlease confirm your password: ");
  511.     input_to( (: ConfirmPassword :), I_NOECHO | I_NOESC, cap, pass);
  512. }
  513.  
  514. static void ConfirmPassword(string control, string cap, string pass) {
  515.     if( control == pass ) {
  516.         Player = master()->player_object(Name);
  517.         pass = crypt(pass, 0);
  518.         Passwort = pass;
  519.         receive("\n\nPlease choose an interesting gender (male, female, neutral, or none): \n");
  520.         input_to((: InputGender :), I_NOESC, cap);
  521.         return;
  522.     }
  523.     receive("\nPassword entries do not match, re-choose password: ");
  524.     input_to((: CreatePassword :), I_NOECHO | I_NOESC, cap);
  525.     return;
  526. }
  527.  
  528. static void InputGender(string str, string cap) {
  529.     if( str != "male" && str != "female"
  530.             && str != "neuter" && str != "neutral" && str != "none") {
  531.         receive("\nCute, but pretend to be male, female, neutral, or none instead.\n");
  532.         receive("Gender: ");
  533.         input_to((: InputGender :), I_NOESC, cap);
  534.         return;
  535.     }
  536.     if(str == "none") str = "neuter";
  537.     Gendre = str;
  538.     if(CUSTOM_FORMAT){
  539.         receive("\nYou may format " + cap + " to appear however you wish "
  540.                 "using spaces, ', or -.\nEnter a display name "
  541.                 "(default: " + cap +"): \n");
  542.         input_to((: InputCapName :), I_NOESC, cap);
  543.     }
  544.     else {
  545.         InputCapName(cap, cap);
  546.     }
  547. }
  548.  
  549. static void InputCapName(string name, string cap) {
  550.     if( !name || name == "" ) name = cap;
  551.     if( !(BANISH_D->valid_cap_name(name, Name)) ) {
  552.         receive("\nThat was not a valid name format, choose again: \n");
  553.         input_to((: InputCapName :), I_NOESC, cap);
  554.         return;
  555.     }
  556.     cap = capitalize(name);
  557.     CapNamen = cap;
  558.     receive("\nFor security reasons, " + mud_name() + " requires a valid "
  559.             "email.\n"
  560.             "Email: \n");
  561.     input_to((: InputEmail :), I_NOESC);
  562. }
  563.  
  564. static void InputEmail(string email) {
  565.     string user, host;
  566.  
  567.     if( !email || sscanf(email, "%s@%s", user, host) != 2 ) {
  568.         receive("\nThat is not a valid email address.\n");
  569.         receive("Please enter a valid email address: \n");
  570.         input_to( (: InputEmail :), I_NOESC );
  571.         return;
  572.     }
  573.     E_Mail = email;
  574.     if(REAL_NAME){
  575.         receive("\nIf you do not mind, please enter your real name "
  576.             "(optional): \n");
  577.         input_to( (: InputRealName :), I_NOESC );
  578.     }
  579.     else {
  580.         InputRealName("");
  581.     }
  582. }
  583.  
  584. static void InputRealName(string rname) {
  585.     if( !rname || rname == "" ) rname = "Unknown";
  586.     TrueName = rname;
  587.     if(!HUMANS_ONLY){
  588.         receive("\n\nYou must now pick a race.\n");
  589.         receive("Picking a race influences what physical traits your character "
  590.                 "will have.\n");
  591.         receive("\nYou may issue the following commands:\n");
  592.         receive("\tlist - lists all races from which you can choose\n");
  593.         receive("\thelp - get help on what races mean\n");
  594.         receive("\thelp RACE - (e.g. \"help human\") gives you information on "
  595.                 "a race\n");
  596.         receive("\tpick RACE - pick a particular race for yourself\n");
  597.         receive("\n\tValid races: ");
  598.         receive(implode(sort_array(RACES_D->GetRaces(1), 1), " "));
  599.         receive("\n\nRace: \n");
  600.         input_to((: InputRace :), I_NOESC);
  601.     }
  602.     else InputRace("pick human");
  603. }
  604.  
  605. static void InputRace(string str) {
  606.     string cmd, args;
  607.     string *valid = ( RACES_D->GetRaces(1) || ({}) );
  608.  
  609.     if( str == "" || !str ) {
  610.         receive("\nRace: ");
  611.         input_to((: InputRace :), I_NOESC);
  612.         return;
  613.     }
  614.     if( sscanf(str, "%s %s", cmd, args) != 2 ) {
  615.         cmd = str;
  616.         args = 0;
  617.     }
  618.     if(member_array(cmd, valid) != -1){
  619.         args = cmd;
  620.         cmd = "pick";
  621.     }
  622.     switch(cmd) {
  623.         case "list":
  624.             cmdList();
  625.         return;
  626.  
  627.         case "help":
  628.             cmdHelp(args);
  629.         return;
  630.  
  631.         case "pick":
  632.             cmdPick(args);
  633.         return;
  634.  
  635.         default:
  636.         receive("\nInvalid command.\nRace: \n");
  637.         input_to((: InputRace :), I_NOESC);
  638.         return;
  639.     }
  640. }
  641.  
  642. static void cmdHelp(string args) {
  643.     function f;
  644.     string array races = RACES_D->GetRaces(1);
  645.     string help;
  646.  
  647.     f = function(string str) {
  648.         receive("\nRace: \n");
  649.         input_to((: InputRace :), I_NOESC);
  650.     };
  651.     if( !args ) {
  652.         help = read_file(DIR_PLAYER_HELP + "/races") ||
  653.             "Error reading help file.\n";
  654.         eventPage(explode(help, "\n"), MSG_HELP, f);
  655.         return;
  656.     }
  657.     if( member_array(args = lower_case(args), races) == -1 ) {
  658.         receive("No such race exists.\n\nRace: \n");
  659.         input_to((: InputRace :), I_NOESC);
  660.         return;
  661.     }
  662.     help = RACES_D->GetHelp(args);
  663.     eventPage(explode(help, "\n"), MSG_HELP, f);
  664. }
  665.  
  666. static void cmdList() {
  667.     string list;
  668.  
  669.     list = format_page(sort_array(RACES_D->GetRaces(1), 1), 5);
  670.     receive(list);
  671.     receive("\nRace: \n");
  672.     input_to((: InputRace :), I_NOESC);
  673. }
  674.  
  675. static void cmdPick(string args) {
  676.     if( !args || args == "" ) {
  677.         receive("You must specify a race to pick.\n\nRace: \n");
  678.         input_to((: InputRace :), I_NOESC);
  679.         return;
  680.     }
  681.     if( member_array(args = lower_case(args),
  682.                 RACES_D->GetRaces(1)) == -1 ) {
  683.         receive("No such race.\nRace: \n");
  684.         input_to((: InputRace :), I_NOESC);
  685.         return;
  686.     }
  687.     raza = args;
  688.     if(!AUTO_WIZ){
  689.         if(CLASS_SELECTION){
  690.             eventSelectClass();
  691.             return;
  692.         }
  693.         eventCompleteChar();
  694.     }
  695.     if(AUTO_WIZ == 2) InputCre("creator");
  696.     else {
  697.         receive("This mud has enabled AUTO_WIZ.\n");
  698.         receive("This means that if you wish, you may be automatically \n");
  699.         receive("promoted to creator status. \n\n");
  700.         receive("If you want to be a player, enter: player\n");
  701.         receive("If you want to be a creator, enter: creator\n");
  702.         receive("What is your choice?\n");
  703.         input_to((: InputCre :), I_NOESC);
  704.     }
  705. }
  706.  
  707. static void eventSelectClass(){
  708.     receive("\n\nYou must now pick a class.\n");
  709.     receive("Picking a class influences what skills your character "
  710.             "will have.\n");
  711.     receive("\nYou may issue the following commands:\n");
  712.     receive("\tlist - lists all classes from which you can choose\n");
  713.     receive("\thelp - get help on what classes mean\n");
  714.     receive("\thelp CLASS - (e.g. \"help explorer\") gives you information on "
  715.             "a class\n");
  716.     receive("\tpick CLASS - pick a particular class for yourself\n");
  717.     receive("\n\tValid classes: ");
  718.     receive(implode(sort_array(CLASSES_D->GetClasses(1), 1), " "));
  719.     receive("\nClass: \n");
  720.     input_to((: InputClass :), I_NOESC);
  721. }
  722.  
  723. static void InputClass(string str){
  724.     string cmd, args;
  725.     string *valid = ( CLASSES_D->GetClasses(1) || ({}) );
  726.  
  727.     if( str == "" || !str ) {
  728.         receive("\nClass: ");
  729.         input_to((: InputClass :), I_NOESC);
  730.         return;
  731.     }
  732.     if( sscanf(str, "%s %s", cmd, args) != 2 ) {
  733.         cmd = str;
  734.         args = 0;
  735.     }
  736.     if(member_array(cmd, valid) != -1){
  737.         args = cmd;
  738.         cmd = "pick";
  739.     }
  740.     switch(cmd) {
  741.         case "list":
  742.             cmdListClasses();
  743.         return;
  744.  
  745.         case "help":
  746.             cmdHelpClass(args);
  747.         return;
  748.  
  749.         case "pick":
  750.             cmdPickClass(args);
  751.         return;
  752.  
  753.         default:
  754.         receive("\nInvalid command.\nClass: \n");
  755.         input_to((: InputClass :), I_NOESC);
  756.         return;
  757.     }
  758. }
  759.  
  760. static void cmdHelpClass(string args){
  761.     function f;
  762.     string array Classes = CLASSES_D->GetClasses(1);
  763.     string help;
  764.  
  765.     f = function(string str) {
  766.         receive("\nClass: \n");
  767.         input_to((: InputClass :), I_NOESC);
  768.     };
  769.     if( !args ) {
  770.         help = HELP_D->GetHelp("player documents classes") ||
  771.             "Error reading help file.\n";
  772.         eventPage(explode(help, "\n"), MSG_HELP, f);
  773.         return;
  774.     }
  775.     if( member_array(args = lower_case(args), Classes) == -1 ) {
  776.         receive("No such Class exists.\n\nClass: \n");
  777.         input_to((: InputClass :), I_NOESC);
  778.         return;
  779.     }
  780.     help = HELP_D->GetHelp("classes "+args);
  781.     eventPage(explode(help, "\n"), MSG_HELP, f);
  782. }
  783.  
  784. static void cmdListClasses() {
  785.     string list;
  786.  
  787.     list = format_page(sort_array(CLASSES_D->GetClasses(1), 1), 5);
  788.     receive(list);
  789.     receive("\nClass: \n");
  790.     input_to((: InputClass :), I_NOESC);
  791. }
  792.  
  793. static void cmdPickClass(string args) {
  794.     if( !args || args == "" ) {
  795.         receive("You must specify a class to pick.\n\nClass: \n");
  796.         input_to((: InputClass :), I_NOESC);
  797.         return;
  798.     }
  799.     if( member_array(args = lower_case(args),
  800.                 CLASSES_D->GetClasses(1)) == -1 ) {
  801.         receive("No such Class.\nClass: \n");
  802.         input_to((: InputClass :), I_NOESC);
  803.         return;
  804.     }
  805.     trabajo = args;
  806.     eventCompleteChar();
  807. }
  808.  
  809. int eventCre(string str){
  810.     mixed mixt;
  811.     if(yescre && AUTO_WIZ > 0){
  812.         mixt = load_object("/secure/cmds/admins/encre")->cmd(str);
  813.     }
  814.     destruct(this_object());
  815.     return 1;
  816. }
  817.  
  818. int eventCheckPending(string str){
  819.     mixed mixt;
  820.     str = lower_case(str);
  821.     if(member_array(str,PLAYERS_D->GetPendingEncres()) != -1){
  822.         PLAYERS_D->RemovePendingEncre(str);
  823.         mixt = load_object("/secure/cmds/admins/encre")->cmd(str);
  824.     }
  825.     else if(member_array(str,PLAYERS_D->GetPendingDecres()) != -1){
  826.         PLAYERS_D->RemovePendingDecre(str);
  827.         mixt = load_object("/secure/cmds/admins/decre")->cmd(str);
  828.     }
  829.     if(member_array(str,PLAYERS_D->GetPendingPauses()) != -1){
  830.         PLAYERS_D->RemovePendingPause(str);
  831.         mixt = Player->SetPlayerPaused(1);
  832.     }
  833.     else if(member_array(str,PLAYERS_D->GetPendingUnpauses()) != -1){
  834.         PLAYERS_D->RemovePendingUnpause(str);
  835.         mixt = Player->SetPlayerPaused(0);
  836.     }
  837.     destruct(this_object());
  838.     return 1;
  839. }
  840.  
  841. void InputCre(string str){
  842.     if(!str || str == "" || !sizeof(str) || !stringp(str)) str = "foo";
  843.     if(str != "creator" && str != "player"){
  844.         receive("\nInvalid choice.\n");
  845.         receive("If you want to be a player, enter: player\n");
  846.         receive("If you want to be a creator, enter: creator\n");
  847.         receive("What is your choice?\n");
  848.         input_to((: InputCre :), I_NOESC);
  849.         return;
  850.     }
  851.     if(str == "creator"){
  852.         yescre = 1;
  853.         receive("\n---\nYou will automatically be made a creator shortly");
  854.         receive(" after login.\n---\n");
  855.     }
  856.     if(CLASS_SELECTION){
  857.         eventSelectClass();
  858.         return;
  859.     }
  860.     else {
  861.         eventCompleteChar();
  862.     }
  863. }
  864.  
  865. void eventCompleteChar(){
  866.     Player->SetRace(raza);
  867.     Player->SetProperty("brand_spanking_new",1);
  868.     Player->AddCurrency("silver",random(100)+57);
  869.     Player->SetPassword(Passwort);
  870.     Player->SetGender(Gendre);
  871.     Player->SetCapName(CapNamen);
  872.     Player->SetEmail(E_Mail);
  873.     Player->SetRealName(TrueName);    
  874.     if(lower_case(raza) != "poleepkwa"){
  875.         Player->SetLanguage("Common",100);    
  876.         Player->SetDefaultLanguage("Common");
  877.         this_player()->SetWimpy(20);
  878.     }
  879.     else {
  880.         Player->SetGender("neutral");
  881.     }
  882.     if(blindmode){
  883.         Player->SetProperty("wizmapping", 0);
  884.         Player->SetProperty("minimapping", 0);
  885.         Player->SetProperty("screen reader", 1);
  886.     }
  887.     if(yescre) Player->SetPrompt("cwd");
  888.     else Player->SetPrompt("status");
  889.     if(trabajo) Player->ChangeClass(trabajo);
  890.     this_player()->SetTerminal("ansi");
  891.     PLAYERS_D->AddPlayerInfo(Name);
  892.     call_out( (: eventCre, Name :), 3);
  893.     eventEnterGame();
  894. }
  895.  
  896. static void eventTimeout() {
  897.     if( !interactive(this_object()) ) {
  898.         Destruct();
  899.     }
  900.     else if( query_idle(this_object()) > LOGON_TIMEOUT ) {
  901.         receive("\nLogin timed out.\n");
  902.         Destruct();
  903.     }
  904.     else call_out( (: eventTimeout :), LOGON_TIMEOUT );
  905. }
  906.  
  907. varargs int eventPrint(string msg, mixed cl, mixed arg3) {
  908.     if( !cl || !intp(cl) ) return 0;
  909.     if( cl & MSG_NOWRAP ) receive(strip_colours(msg));
  910.     else receive(wrap(strip_colours(msg), GetScreen()[0]));
  911.     return 1;
  912. }
  913.  
  914. static private void Destruct() {
  915.     if( Player && !NetDead ) destruct(Player);
  916.     remove_call_out();
  917.     destruct(this_object());
  918. }
  919.  
  920. void eventDestruct() {
  921.     Destruct();
  922. }
  923.  
  924. string GetKeyName() {
  925.     if(!interactive(this_object())) return 0;
  926.     else if(Name) return Name;
  927.     else return "";
  928. }
  929.  
  930. string GetCapName() {
  931.     string tmp;
  932.  
  933.     tmp = GetKeyName();
  934.     return (tmp ? capitalize(tmp) : "");
  935. }
  936.  
  937. static void terminal_type(string str) {
  938.     if( !stringp(str) ) return;
  939.     else Terminal = lower_case(str);
  940. }
  941.  
  942. static void window_size(int width, int height) {
  943.     Screen = ({ width, height });
  944. }
  945.  
  946. static void CreateGuest() {
  947.     receive("Enter the name you wish to use: \n");
  948.     input_to( (: GetGuestName :), I_NOESC );
  949. }
  950.  
  951. static void GetGuestName(string nom) {
  952.     object ob;
  953.  
  954.     return;
  955.     if( !nom || nom == "" || user_exists(convert_name(nom)) ) {
  956.         receive("Illegal name choice, try again: ");
  957.         return;
  958.     }
  959.     ob->SetCapName(nom);
  960.     exec(ob, this_object());
  961.     ob->Setup();
  962. }
  963.  
  964. int *GetScreen() {
  965.     if( Screen ) return Screen;
  966.     else return ({ 79, 25 });
  967. }
  968.  
  969. void SetLastError(mapping m) {
  970.     if (previous_object() != master()) return;
  971.     LastError = m;
  972. }
  973.  
  974. mapping GetLastError() {
  975.     string caller = base_name(previous_object());
  976.     if( caller == "/secure/cmds/creator/dbxwhere" ||
  977.             caller  == "/secure/cmds/player/dbxframe" ) return LastError;
  978.     error("Privilege Violation: " + caller);
  979. }
  980.  
  981. int GetMaxPlayers(){
  982.     return MaxPlayers;
  983. }
  984.  
  985. void receive_environ(mixed foo){
  986.     mixed *uservars;
  987.     uservars = explode(foo, sprintf("%c", __ANSI_SUBSTITUTE__));
  988.     foreach(string uservar in uservars){
  989.         mixed tmp_arr = explode(uservar, sprintf("%c", 1));
  990.         if(!sizeof(tmp_arr)) continue;
  991.         if(sizeof(tmp_arr) < 2) tmp_arr += ({ 0 });
  992.         UserVars[tmp_arr[0]] = tmp_arr[1];
  993.     }
  994.     if(!telopt_user && UserVars["USER"]) telopt_user = UserVars["USER"];
  995. }
Add Comment
Please, Sign In to add comment