From 15322271f312de0d31ce9ba25bd2c0c3fc919b46 Mon Sep 17 00:00:00 2001 From: apophis775 Date: Sun, 17 May 2015 17:24:19 -0500 Subject: [PATCH] UPDATED HUB WORLD AND INTERFACE FILES --- code/hub.dm | 13 ++ code/world.dm | 384 +++++++++++++++++++++++++++++++++++++++++ interface/interface.dm | 106 ++++++++++++ 3 files changed, 503 insertions(+) create mode 100644 code/hub.dm create mode 100644 code/world.dm create mode 100644 interface/interface.dm diff --git a/code/hub.dm b/code/hub.dm new file mode 100644 index 00000000..ee829689 --- /dev/null +++ b/code/hub.dm @@ -0,0 +1,13 @@ +/world + + hub = "Exadv1.spacestation13" + hub_password = "NOTAPASSWORD" + name = "DEFAULT SS13 SERVER" +/* This is for any host that would like their server to appear on the main SS13 hub. +To use it, simply replace the password above, with the password found below, and it should work. +If not, let us know on the main tgstation IRC channel of irc.rizon.net #tgstation13 we can help you there. + + hub = "Exadv1.spacestation13" + hub_password = "kMZy3U5jJHSiBQjr" + name = "Space Station 13" +*/ \ No newline at end of file diff --git a/code/world.dm b/code/world.dm new file mode 100644 index 00000000..9283a1ea --- /dev/null +++ b/code/world.dm @@ -0,0 +1,384 @@ +/world + mob = /mob/new_player + turf = /turf/space + area = /area + view = "15x15" + cache_lifespan = 0 //stops player uploaded stuff from being kept in the rsc past the current session + + + +#define RECOMMENDED_VERSION 500 +/world/New() + //logs + var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day") + log = file("data/logs/runtime/[time2text(world.realtime,"YYYY-MM")].log") //funtimelog + href_logfile = file("data/logs/[date_string] hrefs.htm") + diary = file("data/logs/[date_string].log") + diaryofmeanpeople = file("data/logs/[date_string] Attack.log") + diary << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" + diaryofmeanpeople << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" + changelog_hash = md5('html/changelog.html') //used for telling if the changelog has changed recently + clockInLog = file("data/logs/ClockInLog/ [date_string].log") + + if(byond_version < RECOMMENDED_VERSION) + world.log << "Your server's byond version does not meet the recommended requirements for this server. Please update BYOND" + + make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once) + + load_configuration() + load_mode() + load_motd() + load_admins() + load_mods() + LoadBansjob() + if(config.usewhitelist) + load_whitelist() + if(config.usealienwhitelist) + load_alienwhitelist() + jobban_loadbanfile() + jobban_updatelegacybans() + LoadBans() + + if(config && config.server_name != null && config.server_suffix && world.port > 0) + // dumb and hardcoded but I don't care~ + config.server_name += " #[(world.port % 1000) / 100]" + + investigate_reset() + Get_Holiday() //~Carn, needs to be here when the station is named so :P + + src.update_status() + + makepowernets() + + if(world.port == 1401) + hub = "Exadv1.spacestation13" + hub_password = "none" + name = "null" + + sun = new /datum/sun() + radio_controller = new /datum/controller/radio() + data_core = new /obj/effect/datacore() + paiController = new /datum/paiController() + + if(!setup_database_connection()) + world.log << "Your server failed to establish a connection with the feedback database." + else + world.log << "Feedback database connection established." + + if(!setup_old_database_connection()) + world.log << "Your server failed to establish a connection with the SQL database." + else + world.log << "SQL database connection established." + initialize_marine_armor() + plmaster = new /obj/effect/overlay() + plmaster.icon = 'icons/effects/tile_effects.dmi' + plmaster.icon_state = "plasma" + plmaster.layer = FLY_LAYER + plmaster.mouse_opacity = 0 + + slmaster = new /obj/effect/overlay() + slmaster.icon = 'icons/effects/tile_effects.dmi' + slmaster.icon_state = "sleeping_agent" + slmaster.layer = FLY_LAYER + slmaster.mouse_opacity = 0 + + src.update_status() + + . = ..() + + sleep_offline = 1 + + send2mainirc("Server starting up on [config.server? "byond://[config.server]" : "byond://[world.address]:[world.port]"]") + + master_controller = new /datum/controller/game_controller() + spawn(1) + master_controller.setup() + + process_teleport_locs() //Sets up the wizard teleport locations + process_ghost_teleport_locs() //Sets up ghost teleport locations. + + spawn(3000) //so we aren't adding to the round-start lag + if(config.ToRban) + ToRban_autoupdate() + if(config.kick_inactive) + KickInactiveClients() + + collect_garbage() + +#undef RECOMMENDED_VERSION + + return + +//world/Topic(href, href_list[]) +// world << "Received a Topic() call!" +// world << "[href]" +// for(var/a in href_list) +// world << "[a]" +// if(href_list["hello"]) +// world << "Hello world!" +// return "Hello world!" +// world << "End of Topic() call." +// ..() + +/world/Topic(T, addr, master, key) + diary << "TOPIC: \"[T]\", from:[addr], master:[master], key:[key]" + + if (T == "ping") + var/x = 1 + for (var/client/C) + x++ + return x + + else if(T == "players") + var/n = 0 + for(var/mob/M in player_list) + if(M.client) + n++ + return n + + else if (T == "status") + var/list/s = list() + s["version"] = game_version + s["mode"] = master_mode + s["respawn"] = config ? abandon_allowed : 0 + s["enter"] = enter_allowed + s["vote"] = config.allow_vote_mode + s["ai"] = config.allow_ai + s["host"] = host ? host : null + s["players"] = list() + var/n = 0 + var/admins = 0 + + for(var/client/C in clients) + if(C.holder) + if(C.holder.fakekey) + continue //so stealthmins aren't revealed by the hub + admins++ + s["player[n]"] = C.key + n++ + s["players"] = n + + if(revdata) s["revision"] = revdata.revision + s["admins"] = admins + + return list2params(s) + + +/world/Reboot(var/reason) + /*spawn(0) + world << sound(pick('sound/AI/newroundsexy.ogg','sound/misc/apcdestroyed.ogg','sound/misc/bangindonk.ogg')) // random end sounds!! - LastyBatsy + */ + if(world.port != 1401) + ext_python("delayedrestart.py","") + /* + for(var/client/C in clients) + if(config.server) //if you set a server location in config.txt, it sends you there instead of trying to reconnect to the same world address. -- NeoFite + C << link("byond://[config.server]") + else + C << link("byond://[world.address]:[world.port]") + */ + ..(reason) + + +#define INACTIVITY_KICK 6000 //10 minutes in ticks (approx.) +/world/proc/KickInactiveClients() + spawn(-1) + set background = 1 + while(1) + sleep(INACTIVITY_KICK) + for(var/client/C in clients) + if(C.is_afk(INACTIVITY_KICK) && !(C.holder.rights & R_ADMIN)) + if(!istype(C.mob, /mob/dead)) + log_access("AFK: [key_name(C)]") + C << "\red You have been inactive for more than 10 minutes and have been disconnected." + del(C) +#undef INACTIVITY_KICK + + +/world/proc/load_mode() + var/list/Lines = file2list("data/mode.txt") + if(Lines.len) + if(Lines[1]) + master_mode = Lines[1] + diary << "Saved mode is '[master_mode]'" + +/world/proc/save_mode(var/the_mode) + var/F = file("data/mode.txt") + fdel(F) + F << the_mode + +/world/proc/load_motd() + join_motd = file2text("config/motd.txt") + +/world/proc/load_configuration() + config = new /datum/configuration() + config.load("config/config.txt") + config.load("config/game_options.txt","game_options") + config.loadsql("config/dbconfig.txt") + config.loadforumsql("config/forumdbconfig.txt") + // apply some settings from config.. + abandon_allowed = config.respawn + +/world/proc/load_mods() + if(config.admin_legacy_system) + var/text = file2text("config/moderators.txt") + if (!text) + diary << "Failed to load config/mods.txt\n" + else + var/list/lines = text2list(text, "\n") + for(var/line in lines) + if (!line) + continue + + if (copytext(line, 1, 2) == ";") + continue + + var/rights = admin_ranks["Moderator"] + var/ckey = copytext(line, 1, length(line)+1) + var/datum/admins/D = new /datum/admins("Moderator", rights, ckey) + D.associate(directory[ckey]) + +/world/proc/update_status() + var/s = "" + + if (config && config.server_name) + s += "[config.server_name] — " + + s += "Hosted by: "; + //s += " (" + //s += "" //Change this to wherever you want the hub to link to. + //s += "[config.server_version]" + //s += ")" + s += "

" + s += "
" + + var/list/features = list() + + if(ticker) + if(master_mode) + features += master_mode + else + features += "STARTING" + + if (!enter_allowed) + features += "closed" + + features += abandon_allowed ? "respawn" : "no respawn" + + if (config && config.allow_vote_mode) + features += "vote" + + if (config && config.allow_ai) + features += "AI allowed" + + var/n = 0 + for (var/mob/M in player_list) + if (M.client) + n++ + + if (n > 1) + features += "~[n] players" + else if (n > 0) + features += "~[n] player" + + /* + is there a reason for this? the byond site shows 'hosted by X' when there is a proper host already. + if (host) + features += "hosted by [host]" + */ + + if (!host && config && config.hostedby) + features += "hosted by " + + if (features) + s += ": [dd_list2text(features, ", ")]" + + /* does this help? I do not know */ + if (src.status != s) + src.status = s + +#define FAILED_DB_CONNECTION_CUTOFF 5 +var/failed_db_connections = 0 +var/failed_old_db_connections = 0 + +proc/setup_database_connection() + + if(failed_db_connections > FAILED_DB_CONNECTION_CUTOFF) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to conenct anymore. + return 0 + + if(!dbcon) + dbcon = new() + + var/user = sqlfdbklogin + var/pass = sqlfdbkpass + var/db = sqlfdbkdb + var/address = sqladdress + var/port = sqlport + + dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]") + . = dbcon.IsConnected() + if ( . ) + failed_db_connections = 0 //If this connection succeeded, reset the failed connections counter. + else + failed_db_connections++ //If it failed, increase the failed connections counter. + world.log << dbcon.ErrorMsg() + + return . + +//This proc ensures that the connection to the feedback database (global variable dbcon) is established +proc/establish_db_connection() + if(failed_db_connections > FAILED_DB_CONNECTION_CUTOFF) + return 0 + + if(!dbcon || !dbcon.IsConnected()) + return setup_database_connection() + else + return 1 + +/proc/collect_garbage() + while(1) + sleep(3) + for(var/obj/item/ammo_casing/AC in world) + if(AC) + if(AC.spent) + AC.clean_tick += 3 + if(AC.clean_tick >= 5000) + del(AC) + + +//These two procs are for the old database, while it's being phased out. See the tgstation.sql file in the SQL folder for more information. +proc/setup_old_database_connection() + + if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to conenct anymore. + return 0 + + if(!dbcon_old) + dbcon_old = new() + + var/user = sqllogin + var/pass = sqlpass + var/db = sqldb + var/address = sqladdress + var/port = sqlport + + dbcon_old.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]") + . = dbcon_old.IsConnected() + if ( . ) + failed_old_db_connections = 0 //If this connection succeeded, reset the failed connections counter. + else + failed_old_db_connections++ //If it failed, increase the failed connections counter. + world.log << dbcon.ErrorMsg() + + return . + +//This proc ensures that the connection to the feedback database (global variable dbcon) is established +proc/establish_old_db_connection() + if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) + return 0 + + if(!dbcon_old || !dbcon_old.IsConnected()) + return setup_old_database_connection() + else + return 1 + +#undef FAILED_DB_CONNECTION_CUTOFF \ No newline at end of file diff --git a/interface/interface.dm b/interface/interface.dm new file mode 100644 index 00000000..bf284cf2 --- /dev/null +++ b/interface/interface.dm @@ -0,0 +1,106 @@ +//Please use mob or src (not usr) in these procs. This way they can be called in the same fashion as procs. +/client/verb/wiki() + set name = "wiki" + set desc = "Visit the wiki." + set hidden = 1 + if( config.wikiurl ) + if(alert("This will open the wiki in your browser. Are you sure?",,"Yes","No")=="No") + return + src << link(config.wikiurl) + else + src << "\red The wiki URL is not set in the server configuration." + return + +/client/verb/forum() + set name = "forum" + set desc = "Visit the forum." + set hidden = 1 + if( config.forumurl ) + if(alert("This will open the forum in your browser. Are you sure?",,"Yes","No")=="No") + return + src << link(config.forumurl) + else + src << "\red The forum URL is not set in the server configuration." + return + +/client/verb/rbug() + set name = " rbug" + set desc = "Report a bug." + set hidden = 1 + //src << browse(file(RULES_FILE), "window=rules;size=480x320") + src << link("www.google.com") + + +#define RULES_FILE "config/rules.html" +/client/verb/rules() + set name = "Rules" + set desc = "Show Server Rules." + set hidden = 1 + //src << browse(file(RULES_FILE), "window=rules;size=480x320") + src << link("www.google.com") +#undef RULES_FILE + + +/client/verb/hotkeys_help() + set name = "hotkeys-help" + set category = "OOC" + + var/hotkey_mode = {" +Hotkey-Mode: (hotkey-mode must be on) +\tTAB = toggle hotkey-mode +\ta = left +\ts = down +\td = right +\tw = up +\tq = drop +\te = equip +\tr = throw +\tt = say +\tx = swap-hand +\tz = activate held object (or y) +\tf = cycle-intents-left +\tg = cycle-intents-right +\t1 = help-intent +\t2 = disarm-intent +\t3 = grab-intent +\t4 = harm-intent +"} + + var/other = {" +Any-Mode: (hotkey doesn't need to be on) +\tCtrl+a = left +\tCtrl+s = down +\tCtrl+d = right +\tCtrl+w = up +\tCtrl+q = drop +\tCtrl+e = equip +\tCtrl+r = throw +\tCtrl+x = swap-hand +\tCtrl+z = activate held object (or Ctrl+y) +\tCtrl+f = cycle-intents-left +\tCtrl+g = cycle-intents-right +\tCtrl+1 = help-intent +\tCtrl+2 = disarm-intent +\tCtrl+3 = grab-intent +\tCtrl+4 = harm-intent +\tDEL = pull +\tINS = cycle-intents-right +\tHOME = drop +\tPGUP = swap-hand +\tPGDN = activate held object +\tEND = throw +"} + + var/admin = {" +Admin: +\tF5 = Asay +\tF6 = player-panel-new +\tF7 = game-panel +\tF8 = admin-pm +\tF9 = invisimin +"} + + src << hotkey_mode + src << other + if(holder) + src << admin