Example #1
0
        // Function from file: communications.dm
        public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null)
        {
            dynamic CM         = null;
            Mob     M          = null;
            dynamic I          = null;
            dynamic pda        = null;
            Mob     M2         = null;
            dynamic I2         = null;
            dynamic pda2       = null;
            int     old_level  = 0;
            dynamic title      = null;
            dynamic text       = null;
            string  input      = null;
            string  input2     = null;
            string  input3     = null;
            dynamic title2     = null;
            dynamic text2      = null;
            int     old_level2 = 0;


            if (Lang13.Bool(base.Topic(href, href_list, (object)(hsrc))))
            {
                return(null);
            }

            if (this.z > 2)
            {
                Task13.User.WriteMsg("<span class='boldannounce'>Unable to establish a connection</span>: ΓΏ\"You're too far away from the station!");
                return(null);
            }
            Task13.User.set_machine(this);

            if (!Lang13.Bool(href_list["operation"]))
            {
                return(null);
            }
            CM = this.circuit;

            dynamic _d = href_list["operation"];             // Was a switch-case, sorry for the mess.

            if (_d == "main")
            {
                this.state = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "login")
            {
                M = Task13.User;
                I = M.get_active_hand();

                if (I is Obj_Item_Device_Pda)
                {
                    pda = I;
                    I   = pda.id;
                }

                if (Lang13.Bool(I) && I is Obj_Item_Weapon_Card_Id)
                {
                    if (this.check_access(I))
                    {
                        this.authenticated = 1;
                        this.auth_id       = "" + I.registered_name + " (" + I.assignment + ")";

                        if (Lang13.Bool(I.access.Contains(20)))
                        {
                            this.authenticated = 2;
                        }
                    }

                    if (Lang13.Bool(this.emagged))
                    {
                        this.authenticated = 2;
                        this.auth_id       = "Unknown";
                    }
                }
            }
            else if (_d == "logout")
            {
                this.authenticated = 0;
            }
            else if (_d == "swipeidseclevel")
            {
                M2 = Task13.User;
                I2 = M2.get_active_hand();

                if (I2 is Obj_Item_Device_Pda)
                {
                    pda2 = I2;
                    I2   = pda2.id;
                }

                if (Lang13.Bool(I2) && I2 is Obj_Item_Weapon_Card_Id)
                {
                    if (Lang13.Bool(I2.access.Contains(GlobalVars.access_captain)))
                    {
                        old_level = GlobalVars.security_level;

                        if (!Lang13.Bool(this.tmp_alertlevel))
                        {
                            this.tmp_alertlevel = 0;
                        }

                        if ((this.tmp_alertlevel ?? 0) < 0)
                        {
                            this.tmp_alertlevel = 0;
                        }

                        if ((this.tmp_alertlevel ?? 0) > 1)
                        {
                            this.tmp_alertlevel = 1;
                        }
                        GlobalFuncs.set_security_level(this.tmp_alertlevel);

                        if (GlobalVars.security_level != old_level)
                        {
                            GlobalFuncs.log_game("" + GlobalFuncs.key_name(Task13.User) + " has changed the security level to " + GlobalFuncs.get_security_level() + ".");
                            GlobalFuncs.message_admins("" + GlobalFuncs.key_name_admin(Task13.User) + " has changed the security level to " + GlobalFuncs.get_security_level() + ".");

                            switch ((int)(GlobalVars.security_level))
                            {
                            case 0:
                                GlobalFuncs.feedback_inc("alert_comms_green", 1);
                                break;

                            case 1:
                                GlobalFuncs.feedback_inc("alert_comms_blue", 1);
                                break;
                            }
                        }
                        this.tmp_alertlevel = 0;
                    }
                    else
                    {
                        Task13.User.WriteMsg("<span class='warning'>You are not authorized to do this!</span>");
                        this.tmp_alertlevel = 0;
                    }
                    this.state = GlobalVars.STATE_DEFAULT ?1:0;
                }
                else
                {
                    Task13.User.WriteMsg("<span class='warning'>You need to swipe your ID!</span>");
                }
            }
            else if (_d == "announce")
            {
                if (this.authenticated == 2 && !this.message_cooldown)
                {
                    this.make_announcement(Task13.User);
                }
                else if (this.authenticated == 2 && this.message_cooldown)
                {
                    Task13.User.WriteMsg("Intercomms recharging. Please stand by.");
                }
            }
            else if (_d == "callshuttle")
            {
                this.state = GlobalVars.STATE_DEFAULT ?1:0;

                if (this.authenticated != 0)
                {
                    this.state = GlobalVars.STATE_CALLSHUTTLE;
                }
            }
            else if (_d == "callshuttle2")
            {
                if (this.authenticated != 0)
                {
                    GlobalVars.SSshuttle.requestEvac(Task13.User, href_list["call"]);

                    if (GlobalVars.SSshuttle.emergency.timer != 0)
                    {
                        this.post_status("shuttle");
                    }
                }
                this.state = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "cancelshuttle")
            {
                this.state = GlobalVars.STATE_DEFAULT ?1:0;

                if (this.authenticated != 0)
                {
                    this.state = GlobalVars.STATE_CANCELSHUTTLE;
                }
            }
            else if (_d == "cancelshuttle2")
            {
                if (this.authenticated != 0)
                {
                    GlobalVars.SSshuttle.cancelEvac(Task13.User);
                }
                this.state = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "messagelist")
            {
                this.currmsg = 0;
                this.state   = GlobalVars.STATE_MESSAGELIST;
            }
            else if (_d == "viewmessage")
            {
                this.state = GlobalVars.STATE_VIEWMESSAGE;

                if (!Lang13.Bool(this.currmsg))
                {
                    if (Lang13.Bool(href_list["message-num"]))
                    {
                        this.currmsg = String13.ParseNumber(href_list["message-num"]);
                    }
                    else
                    {
                        this.state = GlobalVars.STATE_MESSAGELIST;
                    }
                }
            }
            else if (_d == "delmessage")
            {
                this.state = (Lang13.Bool(this.currmsg) ? GlobalVars.STATE_DELMESSAGE : GlobalVars.STATE_MESSAGELIST);
            }
            else if (_d == "delmessage2")
            {
                if (this.authenticated != 0)
                {
                    if (Lang13.Bool(this.currmsg))
                    {
                        title = this.messagetitle[this.currmsg];
                        text  = this.messagetext[this.currmsg];
                        this.messagetitle.Remove(title);
                        this.messagetext.Remove(text);

                        if (this.currmsg == this.aicurrmsg)
                        {
                            this.aicurrmsg = 0;
                        }
                        this.currmsg = 0;
                    }
                    this.state = GlobalVars.STATE_MESSAGELIST;
                }
                else
                {
                    this.state = GlobalVars.STATE_VIEWMESSAGE;
                }
            }
            else if (_d == "status")
            {
                this.state = GlobalVars.STATE_STATUSDISPLAY;
            }
            else if (_d == "securitylevel")
            {
                this.tmp_alertlevel = String13.ParseNumber(href_list["newalertlevel"]);

                if (!Lang13.Bool(this.tmp_alertlevel))
                {
                    this.tmp_alertlevel = 0;
                }
                this.state = GlobalVars.STATE_CONFIRM_LEVEL;
            }
            else if (_d == "changeseclevel")
            {
                this.state = GlobalVars.STATE_ALERT_LEVEL;
            }
            else if (_d == "emergencyaccess")
            {
                this.state = GlobalVars.STATE_TOGGLE_EMERGENCY;
            }
            else if (_d == "enableemergency")
            {
                GlobalFuncs.make_maint_all_access();
                GlobalFuncs.log_game("" + GlobalFuncs.key_name(Task13.User) + " enabled emergency maintenance access.");
                GlobalFuncs.message_admins("" + GlobalFuncs.key_name_admin(Task13.User) + " enabled emergency maintenance access.");
                this.state = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "disableemergency")
            {
                GlobalFuncs.revoke_maint_all_access();
                GlobalFuncs.log_game("" + GlobalFuncs.key_name(Task13.User) + " disabled emergency maintenance access.");
                GlobalFuncs.message_admins("" + GlobalFuncs.key_name_admin(Task13.User) + " disabled emergency maintenance access.");
                this.state = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "setstat")
            {
                dynamic _b = href_list["statdisp"];                 // Was a switch-case, sorry for the mess.
                if (_b == "message")
                {
                    this.post_status("message", this.stat_msg1, this.stat_msg2);
                }
                else if (_b == "alert")
                {
                    this.post_status("alert", href_list["alert"]);
                }
                else
                {
                    this.post_status(href_list["statdisp"]);
                }
            }
            else if (_d == "setmsg1")
            {
                this.stat_msg1 = GlobalFuncs.reject_bad_text(Interface13.Input("Line 1", "Enter Message Text", this.stat_msg1, null, null, InputType.Str | InputType.Null), 40);
                this.updateDialog();
            }
            else if (_d == "setmsg2")
            {
                this.stat_msg2 = GlobalFuncs.reject_bad_text(Interface13.Input("Line 2", "Enter Message Text", this.stat_msg2, null, null, InputType.Str | InputType.Null), 40);
                this.updateDialog();
            }
            else if (_d == "MessageCentcomm")
            {
                if (this.authenticated == 2)
                {
                    if (((Obj_Item_Weapon_Circuitboard_Communications)CM).cooldownLeft() != 0)
                    {
                        Task13.User.WriteMsg("Arrays recycling.  Please stand by.");
                        return(null);
                    }
                    input = GlobalFuncs.stripped_input(Task13.User, "Please choose a message to transmit to Centcom via quantum entanglement.  Please be aware that this process is very expensive, and abuse will lead to... termination.  Transmission does not guarantee a response.", "Send a message to Centcomm.", "");

                    if (!Lang13.Bool(input) || !Map13.FetchInView(this, 1).Contains(Task13.User))
                    {
                        return(null);
                    }
                    GlobalFuncs.Centcomm_announce(input, Task13.User);
                    Task13.User.WriteMsg("Message transmitted.");
                    GlobalFuncs.log_say("" + GlobalFuncs.key_name(Task13.User) + " has made a Centcom announcement: " + input);
                    CM.lastTimeUsed = Game13.time;
                }
            }
            else if (_d == "MessageSyndicate")
            {
                if (this.authenticated == 2 && Lang13.Bool(this.emagged))
                {
                    if (((Obj_Item_Weapon_Circuitboard_Communications)CM).cooldownLeft() != 0)
                    {
                        Task13.User.WriteMsg("Arrays recycling.  Please stand by.");
                        return(null);
                    }
                    input2 = GlobalFuncs.stripped_input(Task13.User, "Please choose a message to transmit to [ABNORMAL ROUTING COORDINATES] via quantum entanglement.  Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "Send a message to /??????/.", "");

                    if (!Lang13.Bool(input2) || !Map13.FetchInView(this, 1).Contains(Task13.User))
                    {
                        return(null);
                    }
                    GlobalFuncs.Syndicate_announce(input2, Task13.User);
                    Task13.User.WriteMsg("Message transmitted.");
                    GlobalFuncs.log_say("" + GlobalFuncs.key_name(Task13.User) + " has made a Syndicate announcement: " + input2);
                    CM.lastTimeUsed = Game13.time;
                }
            }
            else if (_d == "RestoreBackup")
            {
                Task13.User.WriteMsg("Backup routing data restored!");
                this.emagged = 0;
                this.updateDialog();
            }
            else if (_d == "nukerequest")
            {
                if (this.authenticated == 2)
                {
                    if (((Obj_Item_Weapon_Circuitboard_Communications)CM).cooldownLeft() != 0)
                    {
                        Task13.User.WriteMsg("Arrays recycling. Please stand by.");
                        return(null);
                    }
                    input3 = GlobalFuncs.stripped_input(Task13.User, "Please enter the reason for requesting the nuclear self-destruct codes. Misuse of the nuclear request system will not be tolerated under any circumstances.  Transmission does not guarantee a response.", "Self Destruct Code Request.", "");

                    if (!Lang13.Bool(input3) || !Map13.FetchInView(this, 1).Contains(Task13.User))
                    {
                        return(null);
                    }
                    GlobalFuncs.Nuke_request(input3, Task13.User);
                    Task13.User.WriteMsg("Request sent.");
                    GlobalFuncs.log_say("" + GlobalFuncs.key_name(Task13.User) + " has requested the nuclear codes from Centcomm");
                    GlobalFuncs.priority_announce("The codes for the on-station nuclear self-destruct have been requested by " + Task13.User + ". Confirmation or denial of this request will be sent shortly.", "Nuclear Self Destruct Codes Requested", "sound/AI/commandreport.ogg");
                    CM.lastTimeUsed = Game13.time;
                }
            }
            else if (_d == "ai-main")
            {
                this.aicurrmsg = 0;
                this.aistate   = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "ai-callshuttle")
            {
                this.aistate = GlobalVars.STATE_CALLSHUTTLE;
            }
            else if (_d == "ai-callshuttle2")
            {
                GlobalVars.SSshuttle.requestEvac(Task13.User, href_list["call"]);
                this.aistate = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "ai-messagelist")
            {
                this.aicurrmsg = 0;
                this.aistate   = GlobalVars.STATE_MESSAGELIST;
            }
            else if (_d == "ai-viewmessage")
            {
                this.aistate = GlobalVars.STATE_VIEWMESSAGE;

                if (!Lang13.Bool(this.aicurrmsg))
                {
                    if (Lang13.Bool(href_list["message-num"]))
                    {
                        this.aicurrmsg = String13.ParseNumber(href_list["message-num"]);
                    }
                    else
                    {
                        this.aistate = GlobalVars.STATE_MESSAGELIST;
                    }
                }
            }
            else if (_d == "ai-delmessage")
            {
                this.aistate = (Lang13.Bool(this.aicurrmsg) ? GlobalVars.STATE_DELMESSAGE : GlobalVars.STATE_MESSAGELIST);
            }
            else if (_d == "ai-delmessage2")
            {
                if (Lang13.Bool(this.aicurrmsg))
                {
                    title2 = this.messagetitle[this.aicurrmsg];
                    text2  = this.messagetext[this.aicurrmsg];
                    this.messagetitle.Remove(title2);
                    this.messagetext.Remove(text2);

                    if (this.currmsg == this.aicurrmsg)
                    {
                        this.currmsg = 0;
                    }
                    this.aicurrmsg = 0;
                }
                this.aistate = GlobalVars.STATE_MESSAGELIST;
            }
            else if (_d == "ai-status")
            {
                this.aistate = GlobalVars.STATE_STATUSDISPLAY;
            }
            else if (_d == "ai-announce")
            {
                if (!this.ai_message_cooldown)
                {
                    this.make_announcement(Task13.User, true);
                }
            }
            else if (_d == "ai-securitylevel")
            {
                this.tmp_alertlevel = String13.ParseNumber(href_list["newalertlevel"]);

                if (!Lang13.Bool(this.tmp_alertlevel))
                {
                    this.tmp_alertlevel = 0;
                }
                old_level2 = GlobalVars.security_level;

                if (!Lang13.Bool(this.tmp_alertlevel))
                {
                    this.tmp_alertlevel = 0;
                }

                if ((this.tmp_alertlevel ?? 0) < 0)
                {
                    this.tmp_alertlevel = 0;
                }

                if ((this.tmp_alertlevel ?? 0) > 1)
                {
                    this.tmp_alertlevel = 1;
                }
                GlobalFuncs.set_security_level(this.tmp_alertlevel);

                if (GlobalVars.security_level != old_level2)
                {
                    GlobalFuncs.log_game("" + GlobalFuncs.key_name(Task13.User) + " has changed the security level to " + GlobalFuncs.get_security_level() + ".");
                    GlobalFuncs.message_admins("" + GlobalFuncs.key_name_admin(Task13.User) + " has changed the security level to " + GlobalFuncs.get_security_level() + ".");

                    switch ((int)(GlobalVars.security_level))
                    {
                    case 0:
                        GlobalFuncs.feedback_inc("alert_comms_green", 1);
                        break;

                    case 1:
                        GlobalFuncs.feedback_inc("alert_comms_blue", 1);
                        break;
                    }
                }
                this.tmp_alertlevel = 0;
                this.aistate        = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "ai-changeseclevel")
            {
                this.aistate = GlobalVars.STATE_ALERT_LEVEL;
            }
            else if (_d == "ai-emergencyaccess")
            {
                this.aistate = GlobalVars.STATE_TOGGLE_EMERGENCY;
            }
            else if (_d == "ai-enableemergency")
            {
                GlobalFuncs.make_maint_all_access();
                GlobalFuncs.log_game("" + GlobalFuncs.key_name(Task13.User) + " enabled emergency maintenance access.");
                GlobalFuncs.message_admins("" + GlobalFuncs.key_name_admin(Task13.User) + " enabled emergency maintenance access.");
                this.aistate = GlobalVars.STATE_DEFAULT ?1:0;
            }
            else if (_d == "ai-disableemergency")
            {
                GlobalFuncs.revoke_maint_all_access();
                GlobalFuncs.log_game("" + GlobalFuncs.key_name(Task13.User) + " disabled emergency maintenance access.");
                GlobalFuncs.message_admins("" + GlobalFuncs.key_name_admin(Task13.User) + " disabled emergency maintenance access.");
                this.aistate = GlobalVars.STATE_DEFAULT ?1:0;
            }
            this.updateUsrDialog();
            return(null);
        }