Exemple #1
0
        // Function from file: world.dm
        public static dynamic Reboot(dynamic reason = null, string feedback_c = null, string feedback_r = null, int?time = null)
        {
            double? delay = null;
            dynamic C     = null;


            if (reason == 1)
            {
                if (Task13.User != null)
                {
                    GlobalFuncs.log_admin("" + GlobalFuncs.key_name(Task13.User) + " Has requested an immediate world restart via client side debugging tools");
                    GlobalFuncs.message_admins("" + GlobalFuncs.key_name_admin(Task13.User) + " Has requested an immediate world restart via client side debugging tools");
                }
                Game13.WriteMsg("<span class='boldannounce'>Rebooting World immediately due to host request</span>");
                return(Game13._internal_Reboot(1, feedback_c, feedback_r, time));
            }

            if (Lang13.Bool(time))
            {
                delay = time;
            }
            else
            {
                delay = (GlobalVars.config.round_end_countdown ?? 0) * 10;
            }

            if (GlobalVars.ticker.delay_end)
            {
                Game13.WriteMsg("<span class='boldannounce'>An admin has delayed the round end.</span>");
                return(null);
            }
            Game13.WriteMsg("<span class='boldannounce'>Rebooting World in " + (delay ?? 0) / 10 + " " + ((delay ?? 0) > 10 ? "seconds" : "second") + ". " + reason + "</span>");
            Task13.Sleep(((int)(delay ?? 0)));

            if (GlobalVars.blackbox != null)
            {
                GlobalVars.blackbox.save_all_data_to_sql();
            }

            if (GlobalVars.ticker.delay_end)
            {
                Game13.WriteMsg("<span class='boldannounce'>Reboot was cancelled by an admin.</span>");
                return(null);
            }
            GlobalFuncs.feedback_set_details("" + feedback_c, "" + feedback_r);
            GlobalFuncs.log_game("<span class='boldannounce'>Rebooting World. " + reason + "</span>");
            GlobalFuncs.kick_clients_in_lobby("<span class='boldannounce'>The round came to an end with you in the lobby.</span>", 1);
            Task13.Schedule(0, (Task13.Closure)(() => {
                if (GlobalVars.ticker != null && Lang13.Bool(GlobalVars.ticker.round_end_sound))
                {
                    Game13.WriteMsg(new Sound(GlobalVars.ticker.round_end_sound));
                }
                else
                {
                    Game13.WriteMsg(new Sound(Rand13.Pick(new object [] { "sound/AI/newroundsexy.ogg", "sound/misc/apcdestroyed.ogg", "sound/misc/bangindonk.ogg", "sound/misc/leavingtg.ogg" })));
                }
                return;
            }));

            foreach (dynamic _a in Lang13.Enumerate(GlobalVars.clients))
            {
                C = _a;


                if (!Lang13.Bool(((dynamic)typeof(Client)).IsInstanceOfType(C)))
                {
                    continue;
                }

                if (Lang13.Bool(GlobalVars.config.server))
                {
                    Interface13.Link(C, "byond://" + GlobalVars.config.server);
                }
            }
            Game13._internal_Reboot(0, feedback_c, feedback_r, time);
            return(null);
        }
Exemple #2
0
        // This is not perfect but if you are passing random shit to this you deserve to get fisted.
        public static dynamic Rotate(object d, double angle)
        {
            if (d is bool || d is int || d is double)
            {
                int dir = Convert.ToInt32(d);

                if (angle == 0)
                {
                    return(dir);
                }

                if (dir == 0)
                {
                    if (Math.Abs(angle) < 45)
                    {
                        return(0);
                    }
                    else
                    {
                        return(Rand13.Pick(new object[] { 1, 2, 4, 5, 6, 8, 9, 10 }));               // I don't f*****g know, man.
                    }
                }

                switch (dir)                   // convert to sane representation
                {
                case 1: dir = 0; break;

                case 2: dir = 4; break;

                case 4: dir = 6; break;

                case 5: dir = 7; break;

                case 6: dir = 5; break;

                case 8: dir = 2; break;

                case 9: dir = 1; break;

                case 10: dir = 3; break;

                default: throw new Exception("DON'T KNOW THIS DIR: " + dir);
                }

                // turn
                int turns = (int)angle / 45;
                dir += turns;
                dir %= 8;

                if (dir < 0)
                {
                    dir += 8;
                }

                dir = dirs[dir];                 // convert back to insane representation
                //Console.Write("``");
                return(dir);
            }
            else
            {
                throw new Exception("Can't rotate this: " + d);
            }
        }