diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0f736822a87..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -language: generic -sudo: false - -env: - global: - BYOND_MAJOR="514" - BYOND_MINOR="1583" - DM_BUILDFILE="baystation12.dme" - -cache: - directories: - - $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR} - -addons: - apt: - packages: - - libc6-i386 - - libgcc1:i386 - - libstdc++6:i386 - -before_script: - - chmod +x ./install-byond.sh - - ./install-byond.sh - -after_success: - - chmod +x ./send-to-discord.sh - - ./send-to-discord.sh success $WEBHOOK_URL - -after_failure: - - chmod +x ./send-to-discord.sh - - ./send-to-discord.sh failure $WEBHOOK_URL - -script: - - shopt -s globstar - - (! grep 'step_[xy]' maps/**/*.dmm) - - (! grep '\bnew/' **/*.dm) - - source $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin/byondsetup - - bash dm.sh ${DM_BUILDFILE} diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 1c6ddc9aefd..00000000000 --- a/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM xales/byond:512-latest - -ARG BUILD_ARGS -ENV RUNAS=root - -COPY . /bs12 - -WORKDIR /bs12 - -RUN apt-get update && apt-get install -y gosu -RUN scripts/dm.sh $BUILD_ARGS baystation12.dme - -EXPOSE 8000 -VOLUME /bs12/data -VOLUME /bs12/config - -ENTRYPOINT ["./docker-entrypoint.sh"] \ No newline at end of file diff --git a/baystation12.dme b/baystation12.dme index 2add4715535..1c3e4d9afc0 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -244,6 +244,7 @@ #include "code\controllers\autotransfer.dm" #include "code\controllers\configuration.dm" #include "code\controllers\controller.dm" +#include "code\controllers\db.dm" #include "code\controllers\failsafe.dm" #include "code\controllers\globals.dm" #include "code\controllers\hooks-defs.dm" @@ -370,7 +371,7 @@ #include "code\datums\configuration\character_setup_section.dm" #include "code\datums\configuration\configuration_section.dm" #include "code\datums\configuration\custom_section.dm" -#include "code\datums\configuration\database_section.dm" +#include "code\datums\configuration\db_section.dm" #include "code\datums\configuration\donations_section.dm" #include "code\datums\configuration\error_section.dm" #include "code\datums\configuration\events_section.dm" @@ -393,7 +394,6 @@ #include "code\datums\configuration\server_configuration.dm" #include "code\datums\configuration\texts_section.dm" #include "code\datums\configuration\vote_section.dm" -#include "code\datums\configuration\whitelist_section.dm" #include "code\datums\elements\_element.dm" #include "code\datums\elements\connect_loc.dm" #include "code\datums\elements\debris.dm" @@ -1527,7 +1527,6 @@ #include "code\modules\admin\player_notes.dm" #include "code\modules\admin\player_panel.dm" #include "code\modules\admin\regular_announcement.dm" -#include "code\modules\admin\species_ingame_whitelist.dm" #include "code\modules\admin\ticket.dm" #include "code\modules\admin\topic.dm" #include "code\modules\admin\watchlist.dm" @@ -3247,7 +3246,6 @@ #include "code\procs\dbcore.dm" #include "code\procs\hud.dm" #include "code\procs\radio.dm" -#include "code\procs\statistics.dm" #include "interface\interface.dm" #include "interface\skin.dmf" #include "maps\_map_include.dm" diff --git a/code/__defines/rust_g.dm b/code/__defines/rust_g.dm index 35af0798e49..1348acd6a37 100644 --- a/code/__defines/rust_g.dm +++ b/code/__defines/rust_g.dm @@ -80,7 +80,7 @@ /// Add files that match the glob pattern, for example: `config/*`Add the file with the specified path. The extension is optional. #define rustg_cfg_add_source_file(name) RUSTG_CALL(RUST_G, "cfg_add_source_file")(name) -/// Use environment variables. The prefix is optional. +/// Use environment variables. The prefix and the separator are optional. #define rustg_cfg_add_source_env(prefix, separator) RUSTG_CALL(RUST_G, "cfg_add_source_env")(isnull(prefix) ? "" : prefix, isnull(separator) ? "" : separator) #define rustg_cfg_end_builder(...) RUSTG_CALL(RUST_G, "cfg_end_builder")() @@ -479,6 +479,28 @@ /// https://en.wikipedia.org/wiki/Normal-inverse_Gaussian_distribution #define rustg_rand_normal_inverse_gaussian(alpha, beta) text2num(RUSTG_CALL(RUST_G, "rand_normal_inverse_gaussian")(istext(alpha) ? alpha : num2text(alpha), istext(beta) ? beta : num2text(beta))) +/// addr - A folder path or an IP address. +/// ns - Namespace. +/// db - Database name. +/// login - Root login. Optional. +/// pass - Root password. Optional. +#define rustg_sdb_connect(addr, ns, db, login, pass) RUSTG_CALL(RUST_G, "sdb_connect")(addr, ns, db, isnull(login) ? "" : login, isnull(pass) ? "" : pass) + +/// Executes a query. +/// query - The query itself. +/// binds - a JSON encoded string, for example: `"{ \"some_arg\": \"Value\" }"`. Optional. +#define rustg_sdb_query(query, binds) RUSTG_CALL(RUST_G, "sdb_query")(query, isnull(binds) ? "" : binds) + +/// Import an SQL file. +/// path - Path to the SQL file. +#define rustg_sdb_import(path) RUSTG_CALL(RUST_G, "sdb_import")(path) + +/// Dumps the database into the SQL file. +/// path - Path to the file where to save the dump. +#define rustg_sdb_export(path) RUSTG_CALL(RUST_G, "sdb_export")(path) + +#define rustg_sdb_disconnect(...) RUSTG_CALL(RUST_G, "sdb_disconnect")() + #define rustg_raw_read_toml_file(path) json_decode(RUSTG_CALL(RUST_G, "toml_file_to_json")(path) || "null") /proc/rustg_read_toml_file(path) diff --git a/code/_helpers/global_access.dm b/code/_helpers/global_access.dm index 9895003616d..be80dd4b4dc 100644 --- a/code/_helpers/global_access.dm +++ b/code/_helpers/global_access.dm @@ -159,8 +159,6 @@ return global.air_alarm_topic; if("air_blocked") return global.air_blocked; - if("alien_whitelist") - return global.alien_whitelist; if("allCasters") return global.allCasters; if("allConsoles") @@ -269,8 +267,6 @@ return global.damage_icon_parts; if("dbcon") return global.dbcon; - if("dbcon_old") - return global.dbcon_old; if("dbcon_don") return global.dbcon_don; if("debug_verbs") @@ -319,8 +315,6 @@ return global.explosion_turfs; if("failed_db_connections") return global.failed_db_connections; - if("failed_old_db_connections") - return global.failed_old_db_connections; if("file_uid") return global.file_uid; if("fileaccess_timer") @@ -757,8 +751,6 @@ return global.weighted_mundaneevent_locations; if("weighted_randomevent_locations") return global.weighted_randomevent_locations; - if("whitelisted_species") - return global.whitelisted_species; if("wireColours") return global.wireColours; if("world_topic_spam_protect_time") @@ -932,8 +924,6 @@ global.air_alarm_topic=newval; if("air_blocked") global.air_blocked=newval; - if("alien_whitelist") - global.alien_whitelist=newval; if("allCasters") global.allCasters=newval; if("allConsoles") @@ -1046,8 +1036,6 @@ global.damage_icon_parts=newval; if("dbcon") global.dbcon=newval; - if("dbcon_old") - global.dbcon_old=newval; if("dbcon_don") global.dbcon_don=newval if("debug_verbs") @@ -1096,8 +1084,6 @@ global.explosion_turfs=newval; if("failed_db_connections") global.failed_db_connections=newval; - if("failed_old_db_connections") - global.failed_old_db_connections=newval; if("file_uid") global.file_uid=newval; if("fileaccess_timer") @@ -1532,8 +1518,6 @@ global.weighted_mundaneevent_locations=newval; if("weighted_randomevent_locations") global.weighted_randomevent_locations=newval; - if("whitelisted_species") - global.whitelisted_species=newval; if("wireColours") global.wireColours=newval; if("world_topic_spam_protect_time") @@ -1635,7 +1619,6 @@ "ai_verbs_default", "air_alarm_topic", "air_blocked", - "alien_whitelist", "allCasters", "allConsoles", "all_grabobjects", @@ -1733,7 +1716,6 @@ "explosion_in_progress", "explosion_turfs", "failed_db_connections", - "failed_old_db_connections", "file_uid", "fileaccess_timer", "finds_as_strings", @@ -2000,8 +1982,6 @@ "wax_recipes", "weighted_mundaneevent_locations", "weighted_randomevent_locations", - "whitelist", - "whitelisted_species", "wireColours", "world_topic_spam_protect_time", "worths", diff --git a/code/_helpers/global_lists.dm b/code/_helpers/global_lists.dm index 7fc15ca8f27..1da81c3cec4 100644 --- a/code/_helpers/global_lists.dm +++ b/code/_helpers/global_lists.dm @@ -27,7 +27,6 @@ GLOBAL_LIST_EMPTY(atmos_machinery) var/global/list/all_species[0] var/global/list/all_languages[0] var/global/list/language_keys[0] // Table of say codes for all languages -var/global/list/whitelisted_species = list(SPECIES_HUMAN) // Species that require a whitelist check. var/global/list/playable_species = list(SPECIES_HUMAN) // A list of ALL playable species, whitelisted, latejoin or otherwise. var/list/mannequins_ @@ -240,8 +239,6 @@ var/global/list/string_slot_flags = list( if(!(S.spawn_flags & SPECIES_IS_RESTRICTED)) playable_species += S.name - if(S.spawn_flags & SPECIES_IS_WHITELISTED) - whitelisted_species += S.name //Posters paths = typesof(/datum/poster) - /datum/poster diff --git a/code/controllers/db.dm b/code/controllers/db.dm new file mode 100644 index 00000000000..6aee04a7354 --- /dev/null +++ b/code/controllers/db.dm @@ -0,0 +1,166 @@ +GLOBAL_REAL(db, /datum/db) = new + +/datum/db/proc/connect() + var/ret = rustg_sdb_connect(config.db.address, config.db.namespace, config.general.server_id, config.db.login, config.db.password) + + if(ret != "") + CRASH("Can't connect to the database: [ret]") + +/datum/db/proc/query(query, binds) + if(!isnull(binds)) + binds = json_encode(binds) + + var/response = rustg_sdb_query(query, binds) + + try + return json_decode(response) + catch + CRASH(response) + +/datum/db/proc/export() + var/ret = rustg_sdb_export("data/database_dump.sql") + + if(ret != "") + CRASH(ret) + +/datum/db/proc/disconnect() + rustg_sdb_disconnect() + +// Whitelist procs + +/datum/db/proc/add_to_whitelist(ckey, whitelist) + query( + {" + IF ( $player) NOT IN ( $whitelist).players THEN + UPDATE ( $whitelist) SET players += ( $player); + END; + "}, + list("player" = "player:[ckey]", "whitelist" = "whitelist:[whitelist]") + ) + +/datum/db/proc/remove_from_whitelist(ckey, whitelist) + query( + {" + UPDATE ( $whitelist) SET players -= ( $player); + "}, + list("player" = "player:[ckey]", "whitelist" = "whitelist:[whitelist]") + ) + +/datum/db/proc/is_in_whitelist(ckey, whitelist) + var/response = query( + "RETURN ( $player) IN ( $whitelist).players;", + list("player" = "player:[ckey]", "whitelist" = "whitelist:[whitelist]") + ) + + return response[1][1] + +// Library procs + +/datum/db/proc/add_library_book(author, title, content, category, author_ckey) + query( + {" + CREATE book CONTENT { + author: $author, + title: $title, + content: $content, + category: $category, + deleted: false, + author_player: ( $author_player) + }; + "}, + list("author" = author, "title" = title, "content" = content, "category" = category, "author_player" = "player:[author_ckey]") + ) + +/datum/db/proc/find_book(book_id) + var/response = query( + {" + SELECT meta::id(id) AS id, title, content, category, author FROM ( $book); + "}, + list("book" = "book:[book_id]") + ) + + return response[1]?[1] + +/datum/db/proc/find_books_with_category(category) + var/response = query( + {" + SELECT meta::id(id) AS id, title, content, category, author FROM book WHERE category = $category; + "}, + list("category" = category) + ) + + return response[1] + +/datum/db/proc/mark_deleted_book(book_id) + var/response = query( + {" + IF ( $book).id IS NOT NONE + { + RETURN UPDATE ( $book) MERGE { + deleted: true + }; + }; + "}, + list("book" = "book:[book_id]") + ) + + return response[1]?[1] + +/datum/db/proc/get_books_ordered(order_by) + var/response = query( + {" + SELECT meta::id(id) AS id, title, category, author FROM book WHERE deleted = false ORDER BY [order_by]; + "} + ) + + return response[1] + +// Art library procs + +/datum/db/proc/add_art(title, type, data, author_ckey) + query( + {" + CREATE art CONTENT { + title: $title, + type: $type, + data: $data, + deleted: false, + author_player: ( $author_player), + }; + "}, + list("title" = title, "type" = type, "data" = data, "author_player" = "player:[author_ckey]") + ) + +/datum/db/proc/find_art(art_id) + var/response = query( + {" + SELECT meta::id(id) AS id, title, data, type FROM ( $art); + "}, + list("art" = "art:[art_id]") + ) + + return response[1]?[1] + +/datum/db/proc/mark_deleted_art(art_id) + var/response = query( + {" + IF ( $art).id IS NOT NONE + { + RETURN UPDATE ( $art) MERGE { + deleted: true + }; + }; + "}, + list("art" = "art:[art_id]") + ) + + return response[1]?[1] + +/datum/db/proc/get_arts_ordered(order_by) + var/response = query( + {" + SELECT meta::id(id) AS id, title, data, type FROM art WHERE deleted = false ORDER BY [order_by]; + "} + ) + + return response[1] diff --git a/code/datums/configuration/database_section.dm b/code/datums/configuration/db_section.dm similarity index 73% rename from code/datums/configuration/database_section.dm rename to code/datums/configuration/db_section.dm index a1edd566522..3b1dc71028c 100644 --- a/code/datums/configuration/database_section.dm +++ b/code/datums/configuration/db_section.dm @@ -1,11 +1,10 @@ -/datum/configuration_section/database +/datum/configuration_section/db name = "db" protection_state = PROTECTION_PRIVATE - // MySQL configuration + // Database configuration var/address - var/port - var/database + var/namespace var/login var/password @@ -13,6 +12,8 @@ var/feedback_database var/feedback_login var/feedback_password + var/feedback_address + var/feedback_port // Donations DB var/donation_address @@ -21,16 +22,17 @@ var/donation_login var/donation_pass -/datum/configuration_section/database/load_data(list/data) +/datum/configuration_section/db/load_data(list/data) CONFIG_LOAD_STR(address, data["address"]) - CONFIG_LOAD_STR(port, data["port"]) - CONFIG_LOAD_STR(database, data["db"]) + CONFIG_LOAD_STR(namespace, data["namespace"]) CONFIG_LOAD_STR(login, data["login"]) CONFIG_LOAD_STR(password, data["password"]) CONFIG_LOAD_STR(feedback_database, data["feedback_database"]) CONFIG_LOAD_STR(feedback_login, data["feedback_login"]) CONFIG_LOAD_STR(feedback_password, data["feedback_password"]) + CONFIG_LOAD_STR(feedback_address, data["feedback_address"]) + CONFIG_LOAD_STR(feedback_port, data["feedback_port"]) CONFIG_LOAD_STR(donation_address, data["donation_address"]) CONFIG_LOAD_STR(donation_port, data["donation_port"]) diff --git a/code/datums/configuration/external_section.dm b/code/datums/configuration/external_section.dm index e0f0e29064d..d05c25cc69b 100644 --- a/code/datums/configuration/external_section.dm +++ b/code/datums/configuration/external_section.dm @@ -2,7 +2,6 @@ name = "external" protection_state = PROTECTION_PRIVATE - var/sql_enabled var/comms_password var/ban_comms_password var/server @@ -10,7 +9,6 @@ var/login_export_addr /datum/configuration_section/external/load_data(list/data) - CONFIG_LOAD_BOOL(sql_enabled, data["sql_enabled"]) CONFIG_LOAD_STR(comms_password, data["comms_password"]) CONFIG_LOAD_STR(ban_comms_password, data["ban_comms_password"]) CONFIG_LOAD_STR(server, data["server"]) diff --git a/code/datums/configuration/server_configuration.dm b/code/datums/configuration/server_configuration.dm index 898237056d4..909c348178f 100644 --- a/code/datums/configuration/server_configuration.dm +++ b/code/datums/configuration/server_configuration.dm @@ -26,12 +26,11 @@ GLOBAL_REAL(config, /datum/server_configuration) = new var/datum/configuration_section/error/error = new var/datum/configuration_section/donations/donations = new var/datum/configuration_section/overmap/overmap = new - var/datum/configuration_section/database/database = new + var/datum/configuration_section/db/db = new var/datum/configuration_section/texts/texts = new var/datum/configuration_section/custom/custom = new var/datum/configuration_section/jobs/jobs = new var/datum/configuration_section/events/events = new - var/datum/configuration_section/whitelist/whitelist = new /// Raw data. Stored here to avoid passing data between procs constantly var/list/raw_data = list() diff --git a/code/datums/configuration/whitelist_section.dm b/code/datums/configuration/whitelist_section.dm deleted file mode 100644 index 7e8210b6303..00000000000 --- a/code/datums/configuration/whitelist_section.dm +++ /dev/null @@ -1,11 +0,0 @@ -/datum/configuration_section/whitelist - name = "whitelist" - - var/enable - var/list/ckeys - var/enable_alien_whitelist - -/datum/configuration_section/whitelist/load_data(list/data) - CONFIG_LOAD_BOOL(enable, data["enable"]) - CONFIG_LOAD_LIST(ckeys, data["ckeys"]) - CONFIG_LOAD_BOOL(enable_alien_whitelist, data["enable_alien_whitelist"]) diff --git a/code/game/jobs/whitelist.dm b/code/game/jobs/whitelist.dm index 19e78af7b75..b8cfeeaf8ea 100644 --- a/code/game/jobs/whitelist.dm +++ b/code/game/jobs/whitelist.dm @@ -1,66 +1,5 @@ -/proc/check_whitelist(mob/M /*, rank*/) - return ("[M.ckey]" in config.whitelist.ckeys) +/proc/is_in_whitelist(ckey) + return db.is_in_whitelist(ckey, "game") -/var/list/alien_whitelist = list() - -/hook/startup/proc/loadAlienWhitelist() - if(config.whitelist.enable_alien_whitelist) - load_alienwhitelist() - - return 1 - -/proc/load_alienwhitelist() - if(!establish_old_db_connection()) - error("Failed to connect to database in load_alienwhitelist().") - log_misc("Failed to connect to database in load_alienwhitelist().") - return FALSE - var/DBQuery/query = sql_query("SELECT * FROM whitelist", dbcon_old) - while(query.NextRow()) - var/list/row = query.GetRowData() - if(alien_whitelist[row["ckey"]]) - var/list/A = alien_whitelist[row["ckey"]] - A.Add(row["race"]) - else - alien_whitelist[row["ckey"]] = list(row["race"]) - return TRUE - -/proc/is_species_whitelisted(mob/M, species_name) - var/datum/species/S = all_species[species_name] - return is_alien_whitelisted(M, S) - -//todo: admin aliens -/proc/is_alien_whitelisted(mob/M, species) - if(!M || !species) - return 0 - if(!config.whitelist.enable_alien_whitelist) - return 1 - - var/client/C = M.client - if (C && SpeciesIngameWhitelist_CheckPlayer(C)) - return TRUE - - if(istype(species,/datum/language)) - var/datum/language/L = species - if(!(L.language_flags & (WHITELISTED|RESTRICTED))) - return 1 - return whitelist_lookup(L.name, M.ckey) - - if(istype(species,/datum/species)) - var/datum/species/S = species - if(!(S.spawn_flags & (SPECIES_IS_WHITELISTED|SPECIES_IS_RESTRICTED))) - return 1 - return whitelist_lookup(S.name, M.ckey) - - return 0 - -/proc/whitelist_lookup(item, ckey) - if(!alien_whitelist) - return 0 - - if(!(ckey in alien_whitelist)) - return 0; - var/list/whitelisted = alien_whitelist[ckey] - if(lowertext(item) in whitelisted) - return 1 - - return 0 +/proc/is_species_whitelisted(ckey, species_name) + return db.is_in_whitelist(ckey, "species_[species_name]") diff --git a/code/game/objects/structures/mirror.dm b/code/game/objects/structures/mirror.dm index aa5bb450a12..0d97aa55f95 100644 --- a/code/game/objects/structures/mirror.dm +++ b/code/game/objects/structures/mirror.dm @@ -110,7 +110,7 @@ /obj/structure/mirror/raider/attack_hand(mob/living/carbon/human/user) if(istype(get_area(src),/area/syndicate_mothership)) - if(istype(user) && user.mind && user.mind.special_role == "Raider" && user.species.name != SPECIES_VOX && is_alien_whitelisted(user, SPECIES_VOX)) + if(istype(user) && user.mind && user.mind.special_role == "Raider" && user.species.name != SPECIES_VOX) var/choice = input("Do you wish to become a true Vox of the Shoal? This is not reversible.") as null|anything in list("No","Yes") if(choice && choice == "Yes") var/mob/living/carbon/human/vox/vox = new(get_turf(src),SPECIES_VOX) diff --git a/code/game/verbs/who.dm b/code/game/verbs/who.dm index de93366d737..9d476d81372 100644 --- a/code/game/verbs/who.dm +++ b/code/game/verbs/who.dm @@ -78,7 +78,7 @@ entry += " (?)" - if(config.external.sql_enabled && watchlist.Check(C.ckey)) + if(watchlist.Check(C.ckey)) entry += " (IN WATCHLIST!)" lines += entry diff --git a/code/game/world.dm b/code/game/world.dm index d27ac5dd37c..16c7aba9c0e 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -152,6 +152,7 @@ var/server_name = "OnyxBay" // Load up the base config.toml config.load_configuration() + db.connect() if(config.general.prometheus_port) to_world_log("Enabled metrics endpoint on [config.general.prometheus_port]") @@ -169,7 +170,7 @@ var/server_name = "OnyxBay" else name = "[server_name] - [GLOB.using_map.full_name]" - if(config && config.game.use_age_restriction_for_jobs != null && config.general.server_suffix && world.port > 0) + if(config.game.use_age_restriction_for_jobs != null && config.general.server_suffix && world.port > 0) // dumb and hardcoded but I don't care~ config.general.server_name += " #[(world.port % 1000) / 100]" @@ -576,6 +577,8 @@ var/world_topic_spam_protect_time = world.timeofday /world/Del() callHook("shutdown") + db.disconnect() + return ..() /world/proc/save_mode(the_mode) @@ -673,19 +676,8 @@ var/world_topic_spam_protect_time = world.timeofday #define FAILED_DB_CONNECTION_CUTOFF 5 var/failed_db_connections = 0 -var/failed_old_db_connections = 0 var/failed_don_db_connections = 0 - -/hook/startup/proc/connectDB() - if(!config.external.sql_enabled) - log_to_dd("SQL disabled. Your server will not use feedback database.") - else if(!setup_database_connection()) - log_to_dd("Your server failed to establish a connection with the feedback database.") - else - log_to_dd("Feedback database connection established.") - return TRUE - /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 connect anymore. return 0 @@ -693,11 +685,11 @@ var/failed_don_db_connections = 0 if(!dbcon) dbcon = new() - var/user = config.database.feedback_login - var/pass = config.database.feedback_password - var/db = config.database.feedback_database - var/address = config.database.address - var/port = config.database.port + var/user = config.db.feedback_login + var/pass = config.db.feedback_password + var/db = config.db.feedback_database + var/address = config.db.feedback_address + var/port = config.db.feedback_port dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]") . = dbcon.IsConnected() @@ -711,9 +703,6 @@ var/failed_don_db_connections = 0 //This proc ensures that the connection to the feedback database (global variable dbcon) is established /proc/establish_db_connection() - if(!config.external.sql_enabled) - return FALSE - if(failed_db_connections > FAILED_DB_CONNECTION_CUTOFF) return FALSE @@ -722,59 +711,8 @@ var/failed_don_db_connections = 0 else return TRUE - -/hook/startup/proc/connectOldDB() - if(!config.external.sql_enabled) - log_to_dd("SQL disabled. Your server configured to use legacy admin and ban system.") - else if(!setup_old_database_connection()) - log_to_dd("Your server failed to establish a connection with the SQL database.") - else - log_to_dd("SQL database connection established.") - return TRUE - -//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. -//If you don't know what any of this do, look at the same code above -/proc/setup_old_database_connection() - - if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) - return 0 - - if(!dbcon_old) - dbcon_old = new() - - var/user = config.database.login - var/pass = config.database.password - var/db = config.database.database - var/address = config.database.address - var/port = config.database.port - - dbcon_old.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]") - . = dbcon_old.IsConnected() - if ( . ) - failed_old_db_connections = 0 - else - failed_old_db_connections++ - to_world_log(dbcon.ErrorMsg()) - - return . - -/proc/establish_old_db_connection() - if(!config.external.sql_enabled) - return FALSE - - if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) - return FALSE - - if(!dbcon_old || !dbcon_old.IsConnected()) - return setup_old_database_connection() - else - return TRUE - - /hook/startup/proc/connectDonDB() - if(!config.external.sql_enabled) - log_to_dd("SQL disabled. Your server will not use Donations database.") - else if(!setup_don_database_connection()) + if(!setup_don_database_connection()) log_to_dd("Your server failed to establish a connection with the Donations database.") else log_to_dd("Donations database connection established.") @@ -782,18 +720,17 @@ var/failed_don_db_connections = 0 //If you don't know what any of this do, look at the same code above proc/setup_don_database_connection() - if(failed_don_db_connections > FAILED_DB_CONNECTION_CUTOFF) return 0 if(!dbcon_don) dbcon_don = new() - var/user = config.database.donation_login - var/pass = config.database.donation_pass - var/db = config.database.donation_database - var/address = config.database.donation_address - var/port = config.database.donation_port + var/user = config.db.donation_login + var/pass = config.db.donation_pass + var/db = config.db.donation_database + var/address = config.db.donation_address + var/port = config.db.donation_port dbcon_don.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]") log_debug("Connecting to donationsDB") @@ -807,9 +744,6 @@ proc/setup_don_database_connection() return . /proc/establish_don_db_connection() - if(!config.external.sql_enabled) - return FALSE - if(failed_don_db_connections > FAILED_DB_CONNECTION_CUTOFF) return FALSE diff --git a/code/modules/admin/EAMS.dm b/code/modules/admin/EAMS.dm index 6a3191ede68..b8f5a088f1e 100644 --- a/code/modules/admin/EAMS.dm +++ b/code/modules/admin/EAMS.dm @@ -40,10 +40,6 @@ SUBSYSTEM_DEF(eams) log_debug("EAMS is disabled by configuration!") return ..() - if(!config.external.sql_enabled) - log_debug("EAMS system is disabled with SQL!") - return ..() - Toggle() return ..() diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index c64fe7f4298..3154018a5f8 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -93,17 +93,13 @@ var/global/floorIsLava = 0 (toggle all) "} - if(config.external.sql_enabled) - if (watchlist.Check(M.client.ckey)) - body += "Remove from Watchlist | " - body += "Edit Watchlist reason " - else - body += "Add to Watchlist " + if (watchlist.Check(M.client.ckey)) + body += "Remove from Watchlist | " + body += "Edit Watchlist reason " else - body += "Watchlist Disabled (Needs SQL)" + body += "Add to Watchlist " body += SSeams.GetPlayerPanelButton(src, M.client) - body += SpeciesIngameWhitelist_GetPlayerPannelButton(src, M.client) body += {"

Jump to | diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm index 4c024dbf2e4..e821ced9290 100644 --- a/code/modules/admin/banjob.dm +++ b/code/modules/admin/banjob.dm @@ -28,8 +28,6 @@ var/const/IAA_ban_reason = "Restricted by CentComm" if (guest_jobbans(rank)) if(config.game.guest_jobban && IsGuestKey(M.key)) return "Guest Job-ban" - if(config.whitelist.enable && !check_whitelist(M)) - return "Whitelisted Job" for (var/s in jobban_keylist) if( findtext(s,"[M.ckey] - [rank]") == 1 ) diff --git a/code/modules/admin/species_ingame_whitelist.dm b/code/modules/admin/species_ingame_whitelist.dm deleted file mode 100644 index 385a9c30556..00000000000 --- a/code/modules/admin/species_ingame_whitelist.dm +++ /dev/null @@ -1,27 +0,0 @@ -// Temporary ingame species whitelist created for test purposes - -/proc/SpeciesIngameWhitelist_GetPlayerPannelButton(datum/admins/source, client/player) - if (!config.whitelist.enable_alien_whitelist) - return - var/result = {"
Species whitelisted: - [player.species_ingame_whitelisted ? "Yes" : "No"] - "} - return result - -/proc/SpeciesIngameWhitelist_AdminTopicProcess(datum/admins/source, list/href_list) - var/client/player = null - if (href_list["addtospeciesingamewhitelist"]) - player = locate(href_list["addtospeciesingamewhitelist"]) - player.species_ingame_whitelisted = TRUE - else if (href_list["removefromspeciesingamewhitelist"]) - player = locate(href_list["removefromspeciesingamewhitelist"]) - player.species_ingame_whitelisted = FALSE - else - return - - source.show_player_panel(player.mob) // update panel - -/proc/SpeciesIngameWhitelist_CheckPlayer(client/player) - if (!config.whitelist.enable_alien_whitelist) - return - return player.species_ingame_whitelisted diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 2bd7b9d71b7..4f2d62556e0 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2127,8 +2127,6 @@ watchlist.AdminTopicProcess(src, href_list) IAAJ_AdminTopicProcess(src, href_list) - SpeciesIngameWhitelist_AdminTopicProcess(src, href_list) - /mob/living/proc/can_centcom_reply() return 0 diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index 026549872af..8502538ad4d 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -17,7 +17,6 @@ var/datum/click_handler/click_handler var/datum/preferences/prefs = null - var/species_ingame_whitelisted = FALSE var/datum/donator_info/donator_info = new diff --git a/code/modules/client/preference_setup/general/02_language.dm b/code/modules/client/preference_setup/general/02_language.dm index 48514714aba..44c61c45b8d 100644 --- a/code/modules/client/preference_setup/general/02_language.dm +++ b/code/modules/client/preference_setup/general/02_language.dm @@ -71,7 +71,7 @@ var/datum/species/S = all_species[pref.species] || all_species[SPECIES_HUMAN] if(lang.name in S.secondary_langs) return TRUE - if(!(lang.language_flags & RESTRICTED) && is_alien_whitelisted(user, lang)) + if(!(lang.language_flags & RESTRICTED)) return TRUE return FALSE diff --git a/code/modules/client/preference_setup/general/03_body.dm b/code/modules/client/preference_setup/general/03_body.dm index 04fe30d1121..e143a84a2ea 100644 --- a/code/modules/client/preference_setup/general/03_body.dm +++ b/code/modules/client/preference_setup/general/03_body.dm @@ -444,8 +444,6 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O dat += "" if(current_species.spawn_flags & SPECIES_CAN_JOIN) dat += "
Often present among humans." - if(current_species.spawn_flags & SPECIES_IS_WHITELISTED & config.whitelist.enable_alien_whitelist) - dat += "
Whitelist restricted." if(!current_species.has_organ[BP_HEART]) dat += "
Does not have blood." if(!current_species.has_organ[BP_LUNGS]) @@ -471,13 +469,6 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O dat += "

" var/restricted = 0 - if(config.whitelist.enable_alien_whitelist) //If we're using the whitelist, make sure to check it! - if (!(current_species.spawn_flags & SPECIES_CAN_JOIN)) - restricted = 2 - else if ((current_species.spawn_flags & SPECIES_IS_WHITELISTED) && !is_alien_whitelisted(preference_mob(),current_species)) - restricted = 1 - else if (jobban_isbanned(user, "SPECIES")) - restricted = 3 if (restricted) if (restricted == 1) diff --git a/code/modules/client/preference_setup/loadout/loadout.dm b/code/modules/client/preference_setup/loadout/loadout.dm index c2a76f79e5b..08e612365b3 100644 --- a/code/modules/client/preference_setup/loadout/loadout.dm +++ b/code/modules/client/preference_setup/loadout/loadout.dm @@ -74,10 +74,6 @@ var/list/hash_to_gear = list() var/okay = 1 if(G.whitelisted && preference_mob) okay = 0 - for(var/species in G.whitelisted) - if(is_species_whitelisted(preference_mob, species)) - okay = 1 - break if(!okay) continue if(max_cost && G.cost > max_cost) @@ -689,7 +685,7 @@ var/list/hash_to_gear = list() var/patron_tier //Patron tier restriction var/slot //Slot to equip to. var/list/allowed_roles //Roles that can spawn with this item. - var/whitelisted //Term to check the whitelist for.. + var/whitelisted //Term to check the whitelist for. var/sort_category = "General" var/flags //Special tweaks in new var/list/gear_tweaks = list() //List of datums which will alter the item after it has been spawned. diff --git a/code/modules/donations/donations.dm b/code/modules/donations/donations.dm index 0d594464536..f0c9e1fbf9b 100644 --- a/code/modules/donations/donations.dm +++ b/code/modules/donations/donations.dm @@ -4,10 +4,6 @@ SUBSYSTEM_DEF(donations) flags = SS_NO_FIRE /datum/controller/subsystem/donations/Initialize(timeofday) - if(!config.external.sql_enabled) - log_debug("Donations system is disabled with SQL!") - return - if(!config.donations.enable) log_debug("Donations system is disabled by configuration!") return @@ -264,10 +260,6 @@ SUBSYSTEM_DEF(donations) set name = ".chaotic-token" set hidden = TRUE - if(!config.external.sql_enabled) - to_chat(usr, "Donations system cannot be used, because SQL is disabled by configuration!") - return - if(!config.donations.enable) to_chat(usr, "Donations system is disabled by configuration!") return diff --git a/code/modules/error_handler/error_handler.dm b/code/modules/error_handler/error_handler.dm index 8966ea58053..17dd18096e9 100644 --- a/code/modules/error_handler/error_handler.dm +++ b/code/modules/error_handler/error_handler.dm @@ -98,8 +98,6 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0) log_runtime(line) // SQL runtime logging - if(!config.external.sql_enabled) - return if(!establish_don_db_connection()) return sql_query({" diff --git a/code/modules/library/lib_items.dm b/code/modules/library/lib_items.dm index c63e7ca5fea..d7e4628699a 100644 --- a/code/modules/library/lib_items.dm +++ b/code/modules/library/lib_items.dm @@ -142,17 +142,7 @@ . = ..() if(!prefit_category) return - if(!establish_old_db_connection()) - return - var/list/potential_books = list() - var/DBQuery/query = sql_query("SELECT * FROM library WHERE category = $category", dbcon_old, list(category = prefit_category)) - while(query.NextRow()) - potential_books.Add(list(list( - "id" = query.item[1], - "author" = query.item[2], - "title" = query.item[3], - "content" = query.item[4] - ))) + var/list/potential_books = db.find_books_with_category(prefit_category) var/list/picked_books = list() for(var/i in 1 to rand(3,5)) if(potential_books.len) diff --git a/code/modules/mob/living/carbon/alien/diona/progression.dm b/code/modules/mob/living/carbon/alien/diona/progression.dm index 4d2c881014a..08b23571440 100644 --- a/code/modules/mob/living/carbon/alien/diona/progression.dm +++ b/code/modules/mob/living/carbon/alien/diona/progression.dm @@ -1,9 +1,4 @@ /mob/living/carbon/alien/diona/confirm_evolution() - - if(!is_species_whitelisted(src, SPECIES_DIONA)) - to_chat(src, alert("You are currently not whitelisted to play as a full diona.")) - return null - if(amount_grown < max_grown) to_chat(src, "You are not yet ready for your growth...") return null diff --git a/code/modules/mob/living/carbon/human/appearance.dm b/code/modules/mob/living/carbon/human/appearance.dm index 9a81b50ba66..e9532b1511e 100644 --- a/code/modules/mob/living/carbon/human/appearance.dm +++ b/code/modules/mob/living/carbon/human/appearance.dm @@ -1,5 +1,5 @@ -/mob/living/carbon/human/proc/change_appearance(flags = APPEARANCE_ALL_HAIR, location = src, mob/user = src, check_species_whitelist = 1, list/species_whitelist = list(), list/species_blacklist = list(), datum/topic_state/state = GLOB.default_state) - var/datum/nano_module/appearance_changer/AC = new(location, src, check_species_whitelist, species_whitelist, species_blacklist) +/mob/living/carbon/human/proc/change_appearance(flags = APPEARANCE_ALL_HAIR, location = src, mob/user = src, list/species_whitelist = list(), list/species_blacklist = list(), datum/topic_state/state = GLOB.default_state) + var/datum/nano_module/appearance_changer/AC = new(location, src, species_whitelist, species_blacklist) AC.flags = flags AC.ui_interact(user, state = state) @@ -174,16 +174,9 @@ dna.ready_dna(src) sync_organ_dna() -/mob/living/carbon/human/proc/generate_valid_species(check_whitelist = 1, list/whitelist = list(), list/blacklist = list()) +/mob/living/carbon/human/proc/generate_valid_species(list/whitelist = list(), list/blacklist = list()) var/list/valid_species = new() for(var/current_species_name in all_species) - var/datum/species/current_species = all_species[current_species_name] - - if(check_whitelist) //If we're using the whitelist, make sure to check it! - if((current_species.spawn_flags & SPECIES_IS_RESTRICTED) && !check_rights(R_ADMIN, 0, src)) - continue - if(!is_alien_whitelisted(src, current_species)) - continue if(whitelist.len && !(current_species_name in whitelist)) continue if(blacklist.len && (current_species_name in blacklist)) diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 1e11d2de68f..3d77eccd16a 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -525,7 +525,7 @@ var/datum/language/chosen_language = all_languages[lang] if(chosen_language) var/is_species_lang = (chosen_language.name in new_character.species.secondary_langs) - if(is_species_lang || ((!(chosen_language.language_flags & RESTRICTED) || has_admin_rights()) && is_alien_whitelisted(src, chosen_language))) + if(is_species_lang || ((!(chosen_language.language_flags & RESTRICTED) || has_admin_rights()))) new_character.add_language(lang) if(GLOB.random_players) @@ -620,10 +620,6 @@ if (show_alert) alert(client, "Your current species, [client.prefs.species], is not available for play.") return 0 - if (!is_alien_whitelisted(src, S)) - if (show_alert) - alert(client, "You are currently not whitelisted to play [client.prefs.species].") - return 0 if (jobban_isbanned(src, "SPECIES") && S.name != SPECIES_HUMAN) if (show_alert) alert(client, "You are currently banned to play species!") diff --git a/code/modules/modular_computers/file_system/programs/generic/artlibrary.dm b/code/modules/modular_computers/file_system/programs/generic/artlibrary.dm index db4e9c4623f..96fd97daf5d 100644 --- a/code/modules/modular_computers/file_system/programs/generic/artlibrary.dm +++ b/code/modules/modular_computers/file_system/programs/generic/artlibrary.dm @@ -19,7 +19,7 @@ name = "Art library" var/error_message = "" var/sort_by = "id" - var/current_art + var/list/current_art var/obj/machinery/libraryscanner/scanner var/static/list/icon_cache = list() var/static/list/canvas_state_to_type = list() @@ -43,35 +43,7 @@ else if(current_art) data["current_art"] = current_art else - var/list/all_entries[0] - if(!establish_old_db_connection()) - error_message = "Unable to contact External Archive. Please contact your system administrator for assistance." - else - try - var/DBQuery/query = sql_query({" - SELECT - id, - ckey, - title, - data, - type - FROM - art_library - ORDER BY - $sort_by - "}, dbcon_old, list(sort_by = sort_by)) - - while(query.NextRow()) - all_entries.Add(list(list( - "id" = query.item[1], - "ckey" = query.item[2], - "title" = query.item[3], - "data" = query.item[4], - "type" = query.item[5] - ))) - catch - error_message = "Unable to receive arts form External Archive. Please contact your system administrator for assistance." - data["art_list"] = all_entries + data["art_list"] = db.get_arts_ordered(sort_by) data["scanner"] = istype(scanner) ui = SSnano.try_update_ui(user, src, ui_key, ui, data, force_open) @@ -118,29 +90,12 @@ return var/choice = input(usr, "Upload [art_cache.painting_name] to the External Archive?") in list("Yes", "No") if(choice == "Yes") - if(!establish_old_db_connection()) - error_message = "Network Error: Connection to the Archive has been severed." - return TRUE - var/DBQuery/query = sql_query({" - INSERT INTO - art_library - (ckey, - title, - data, - type) - VALUES - ($ckey, - $title, - $data, - $type) - "}, dbcon_old, list(ckey = art_cache.author_ckey, title = art_cache.painting_name, data = encoded_data, type = art_cache.icon_state)) - if(!query) - error_message = "Network Error: Unable to upload to the Archive. Contact your system Administrator for assistance." - return TRUE - else - log_and_message_admins("has uploaded the art titled [art_cache.painting_name], [length(encoded_data)] signs of data") - log_game("[usr.name]/[usr.key] has uploaded the art titled [art_cache.painting_name], [length(encoded_data)] signs of data") - alert("Upload Complete.") + db.add_art(art_cache.painting_name, art_cache.icon_state, encoded_data, art_cache.author_ckey) + + log_and_message_admins("has uploaded the art titled [art_cache.painting_name], [length(encoded_data)] signs of data") + log_game("[usr.name]/[usr.key] has uploaded the art titled [art_cache.painting_name], [length(encoded_data)] signs of data") + alert("Upload Complete.") + return TRUE return FALSE @@ -193,47 +148,36 @@ if(current_art || !id) return FALSE - if(!establish_old_db_connection()) - error_message = "Network Error: Connection to the Archive has been severed." + var/list/art = db.find_art(id) + + if(isnull(art)) return TRUE - try - var/DBQuery/query = sql_query("SELECT * FROM art_library WHERE id = $id", dbcon_old, list(id = id)) + var/art_type = art["type"] + var/canvas_type = canvas_state_to_type[art_type] + var/obj/item/canvas/preview_canvas = new canvas_type() + var/art_icon + preview_canvas.icon_generated = FALSE + preview_canvas.apply_canvas_data(art["data"]) + preview_canvas.paint_image() + + var/icon/pre_icon = getFlatIcon(preview_canvas) + switch(art_type) + if("11x11") + pre_icon.Crop(11, 21, 21, 11) + if("19x19") + pre_icon.Crop(8, 27, 26, 9) + if("23x19") + pre_icon.Crop(6, 26, 28, 8) + if("23x23") + pre_icon.Crop(6, 27, 28, 5) + if("24x24") + pre_icon.Crop(5, 27, 28, 4) + art_icon = icon2base64(pre_icon) + icon_cache[art["title"]] = art_icon + current_art = art + QDEL_NULL(preview_canvas) - while(query.NextRow()) - var/art_type = query.item[6] - var/canvas_type = canvas_state_to_type[art_type] - var/obj/item/canvas/preview_canvas = new canvas_type() - var/art_icon - preview_canvas.icon_generated = FALSE - preview_canvas.apply_canvas_data(query.item[4]) - preview_canvas.paint_image() - var/icon/pre_icon = getFlatIcon(preview_canvas) - switch(art_type) - if("11x11") - pre_icon.Crop(11, 21, 21, 11) - if("19x19") - pre_icon.Crop(8, 27, 26, 9) - if("23x19") - pre_icon.Crop(6, 26, 28, 8) - if("23x23") - pre_icon.Crop(6, 27, 28, 5) - if("24x24") - pre_icon.Crop(5, 27, 28, 4) - art_icon = icon2base64(pre_icon) - icon_cache[query.item[3]] = art_icon - current_art = list( - "id" = query.item[1], - "ckey" = query.item[2], - "title" = query.item[3], - "data" = query.item[4], - "icon" = art_icon, - "type" = art_type - ) - QDEL_NULL(preview_canvas) - break - catch - error_message = "Network Error: Connection to the Archive has been severed." return TRUE /proc/del_art_from_db(id, user) @@ -242,21 +186,7 @@ if(!check_rights(R_INVESTIGATE, TRUE, user)) return - if(!establish_db_connection()) - to_chat(user, SPAN_WARNING("Failed to establish database connection!")) - return - - var/author - var/title - var/DBQuery/query = sql_query("SELECT ckey, title FROM art_library WHERE id = $id", dbcon, list(id = id)) - - if(query.NextRow()) - author = query.item[1] - title = query.item[2] - else - to_chat(user, SPAN_WARNING("Art with ISAN number \[[id]\] was not found!")) - return + var/list/art = db.mark_deleted_art(id) - query = sql_query("DELETE FROM art_library WHERE id = $id", dbcon, list(id = id)) - if(query) - log_and_message_admins("has deleted the art: \[[id]\] \"[title]\" by [author]", user) + if(!isnull(art)) + log_and_message_admins("has deleted the art: \[[id]\] \"[art["title"]]\" by [art["author"]]", user) diff --git a/code/modules/modular_computers/file_system/programs/generic/library.dm b/code/modules/modular_computers/file_system/programs/generic/library.dm index 24fc3eb7944..def6718b46d 100644 --- a/code/modules/modular_computers/file_system/programs/generic/library.dm +++ b/code/modules/modular_computers/file_system/programs/generic/library.dm @@ -37,30 +37,7 @@ The answer was five and a half years -ZeroBits else if(current_book) data["current_book"] = current_book else - var/list/all_entries[0] - if(!establish_old_db_connection()) - error_message = "Unable to contact External Archive. Please contact your system administrator for assistance." - else - var/DBQuery/query = sql_query({" - SELECT - id, - author, - title, - category - FROM - library - ORDER BY - $sort_by - "}, dbcon_old, list(sort_by = sort_by)) - - while(query.NextRow()) - all_entries.Add(list(list( - "id" = query.item[1], - "author" = query.item[2], - "title" = query.item[3], - "category" = query.item[4] - ))) - data["book_list"] = all_entries + data["book_list"] = db.get_books_ordered(sort_by) data["scanner"] = istype(scanner) ui = SSnano.try_update_ui(user, src, ui_key, ui, data, force_open) @@ -119,32 +96,13 @@ The answer was five and a half years -ZeroBits var/choice = input(usr, "Upload [B.name] by [B.author] to the External Archive?") in list("Yes", "No") if(choice == "Yes") - if(!establish_old_db_connection()) - error_message = "Network Error: Connection to the Archive has been severed." - return 1 - var/upload_category = input(usr, "Upload to which category?") in list("Fiction", "Non-Fiction", "Reference", "Religion") - var/DBQuery/query = sql_query({" - INSERT INTO - library - (author, - title, - content, - category) - VALUES - ($author, - $title, - $content, - $upload_category) - "}, dbcon_old, list(author = B.author, title = B.name, content = B.dat, upload_category = upload_category)) - if(!query) - error_message = "Network Error: Unable to upload to the Archive. Contact your system Administrator for assistance." - return 1 - else - log_and_message_admins("has uploaded the book titled [B.name], [length(B.dat)] signs") - log_game("[usr.name]/[usr.key] has uploaded the book titled [B.name], [length(B.dat)] signs") - alert("Upload Complete.") + db.add_library_book(B.author, B.name, B.dat, upload_category, usr.ckey) + + log_and_message_admins("has uploaded the book titled [B.name], [length(B.dat)] signs") + log_game("[usr.name]/[usr.key] has uploaded the book titled [B.name], [length(B.dat)] signs") + alert("Upload Complete.") return 1 return 0 @@ -191,48 +149,23 @@ The answer was five and a half years -ZeroBits /datum/nano_module/library/proc/view_book(id) if(current_book || !id) - return 0 - - if(!establish_old_db_connection()) - error_message = "Network Error: Connection to the Archive has been severed." - return 1 + return FALSE - var/DBQuery/query = sql_query("SELECT * FROM library WHERE id = $id", dbcon_old, list(id = id)) + current_book = db.find_book(id) - while(query.NextRow()) - current_book = list( - "id" = query.item[1], - "author" = query.item[2], - "title" = query.item[3], - "content" = query.item[4] - ) - break - return 1 + return TRUE /proc/del_book_from_db(id, user) if(!id || !user) return - if(!check_rights(R_INVESTIGATE, TRUE, user)) - return - if(!establish_db_connection()) - to_chat(user, SPAN_WARNING("Failed to establish database connection!")) + if(!check_rights(R_INVESTIGATE, TRUE, user)) return - var/author - var/title - var/DBQuery/query = sql_query("SELECT author, title FROM library WHERE id = $id", dbcon, list(id = id)) - - if(query.NextRow()) - author = query.item[1] - title = query.item[2] - else - to_chat(user, SPAN_WARNING("Book with ISBN number \[[id]\] was not found!")) - return + var/list/book = db.mark_deleted_book(id) - query = sql_query("DELETE FROM library WHERE id = $id", dbcon, list(id = id)) - if(query) - log_and_message_admins("has deleted the book: \[[id]\] \"[title]\" by [author]", user) + if(!isnull(book)) + log_and_message_admins("has deleted the book: \[[book["id"]]\] \"[book["title"]]\" by [book["author"]]", user) #define WIKI_COMMON_CATEGORY "Available_in_library" #define WIKI_HACKED_CATEGORY "Available_in_hacked_library" diff --git a/code/modules/nano/modules/human_appearance.dm b/code/modules/nano/modules/human_appearance.dm index f87cdf98115..e0f12aea978 100644 --- a/code/modules/nano/modules/human_appearance.dm +++ b/code/modules/nano/modules/human_appearance.dm @@ -7,14 +7,12 @@ var/list/valid_hairstyles = list() var/list/valid_facial_hairstyles = list() - var/check_whitelist var/list/whitelist var/list/blacklist -/datum/nano_module/appearance_changer/New(location, mob/living/carbon/human/H, check_species_whitelist = 1, list/species_whitelist = list(), list/species_blacklist = list()) +/datum/nano_module/appearance_changer/New(location, mob/living/carbon/human/H, list/species_whitelist = list(), list/species_blacklist = list()) ..() owner = H - src.check_whitelist = check_species_whitelist src.whitelist = species_whitelist src.blacklist = species_blacklist @@ -113,7 +111,7 @@ if(!owner || !owner.species) return - generate_data(check_whitelist, whitelist, blacklist) + generate_data(whitelist, blacklist) var/list/data = host.initial_data() data["specimen"] = owner.species.name @@ -184,7 +182,7 @@ if(!owner) return if(!valid_species.len) - valid_species = owner.generate_valid_species(check_whitelist, whitelist, blacklist) + valid_species = owner.generate_valid_species(whitelist, blacklist) if(!valid_hairstyles.len || !valid_facial_hairstyles.len) valid_hairstyles = owner.generate_valid_hairstyles(check_gender = 0) valid_facial_hairstyles = owner.generate_valid_facial_hairstyles() diff --git a/code/procs/dbcore.dm b/code/procs/dbcore.dm index b13a1f211b8..c64ba739aec 100644 --- a/code/procs/dbcore.dm +++ b/code/procs/dbcore.dm @@ -56,8 +56,6 @@ var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is _db_con = _dm_db_new_con() /DBConnection/proc/Connect(dbi_handler=src.dbi,user_handler=src.user,password_handler=src.password,cursor_handler) - if(!config.external.sql_enabled) - return FALSE if(!src) return FALSE cursor_handler = src.default_cursor @@ -69,8 +67,6 @@ var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is /DBConnection/proc/Disconnect() return _dm_db_close(_db_con) /DBConnection/proc/IsConnected() - if(!config.external.sql_enabled) - return FALSE var/success = _dm_db_is_connected(_db_con) return success @@ -80,7 +76,7 @@ var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is /DBConnection/proc/SelectDB(database_name,dbi) if(IsConnected()) Disconnect() //return Connect("[dbi?"[dbi]":"dbi:mysql:[database_name]:[DB_SERVER]:[DB_PORT]"]",user,password) - return Connect("[dbi?"[dbi]":"dbi:mysql:[database_name]:[config.database.address]:[config.database.port]"]",user,password) + return Connect("[dbi?"[dbi]":"dbi:mysql:[database_name]:[config.db.feedback_address]:[config.db.feedback_port]"]",user,password) /DBConnection/proc/NewQuery(sql_query,cursor_handler=src.default_cursor) return new /DBQuery(sql_query,src,cursor_handler) diff --git a/code/procs/statistics.dm b/code/procs/statistics.dm deleted file mode 100644 index e5c32e5520e..00000000000 --- a/code/procs/statistics.dm +++ /dev/null @@ -1,51 +0,0 @@ -//This proc is used for feedback. It is executed at round end. -/proc/sql_commit_feedback() - if(!blackbox) - log_game("Round ended without a blackbox recorder. No feedback was sent to the database.") - return - - //content is a list of lists. Each item in the list is a list with two fields, a variable name and a value. Items MUST only have these two values. - var/list/datum/feedback_variable/content = blackbox.get_round_feedback() - - if(!content) - log_game("Round ended without any feedback being generated. No feedback was sent to the database.") - return - - if(!establish_db_connection()) - log_game("SQL ERROR during feedback reporting. Failed to connect.") - else - - var/DBQuery/max_query = sql_query("SELECT MAX(roundid) AS max_round_id FROM erro_feedback", dbcon) - - var/newroundid - - while(max_query.NextRow()) - newroundid = max_query.item[1] - - if(!(isnum(newroundid))) - newroundid = text2num(newroundid) - - if(isnum(newroundid)) - newroundid++ - else - newroundid = 1 - - for(var/datum/feedback_variable/item in content) - var/variable = item.get_variable() - var/value = item.get_value() - - sql_query({" - INSERT INTO - erro_feedback - (id, - roundid, - time, - variable, - value) - VALUES - (null, - $newroundid, - Now(), - $variable, - $value) - "}, dbcon, list(newroundid = newroundid, variable = variable, value = value)) diff --git a/config/default/database.toml b/config/default/database.toml deleted file mode 100644 index f913c6ff051..00000000000 --- a/config/default/database.toml +++ /dev/null @@ -1,30 +0,0 @@ -# MySQL Connection Configuration - -# Server the MySQL database can be found at -# Examples: localhost, 200.135.5.43, www.mysqldb.com, etc. -[database] -address = "localhost" -# MySQL server port (default is 3306) -port = 3306 -# Database the population, death, karma, etc. tables may be found in -database = "tgstation" -# Username/Login used to access the database -login = "mylogin" -# Password used to access the database -password = "mypassword" - -# The following information is for feedback tracking via the blackbox server -feedback_database = "feedback" -feedback_login = "root" -feedback_password = "pass" - -# Track population and death statistics -# Comment this out to disable -#ENABLE_STAT_TRACKING - -# Third database, external bots can only access it -donation_address = "localhost" -donation_port = 3306 -donation_database = "donations" -donation_login = "root" -donation_password = "pass" diff --git a/config/default/db.toml b/config/default/db.toml new file mode 100644 index 00000000000..0f9de830f2f --- /dev/null +++ b/config/default/db.toml @@ -0,0 +1,19 @@ +[db] +address = "file://data/database" +namespace = "ss13" +login = "" +password = "" + +# The following information is for feedback tracking via the blackbox server +feedback_database = "feedback" +feedback_login = "root" +feedback_password = "pass" +feedback_address = "localhost" +feedback_port = "3306" + +# Third database, external bots can only access it +donation_address = "localhost" +donation_port = 3306 +donation_database = "donations" +donation_login = "root" +donation_password = "pass" diff --git a/config/default/whitelist.toml b/config/default/whitelist.toml deleted file mode 100644 index 7e7f1bbe2b7..00000000000 --- a/config/default/whitelist.toml +++ /dev/null @@ -1,4 +0,0 @@ -[whitelist] -enable = false -ckeys = [] -enable_alien_whitelist = false diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 2d753b1f88d..00000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: "3" -services: - db: - build: ./sql - image: bs12-db:latest - networks: - - internal - volumes: - - "./sql/test_db:/var/lib/mysql" - game: - build: . - image: bs12:latest - networks: - - internal - ports: - - "8000:8000" -networks: - internal: \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index 046817febaa..00000000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -mkdir /byond -chown $RUNAS:$RUNAS /byond /onyxbay baystation12.rsc - -gosu $RUNAS DreamDaemon baystation12.dmb 8000 -trusted -verbose \ No newline at end of file diff --git a/docs/db.md b/docs/db.md index 0994f2ad0b2..dba05de216e 100644 --- a/docs/db.md +++ b/docs/db.md @@ -1,16 +1,43 @@ -# Настройка базы данных +# Базы данных -В билде OnyxBay используются MySQL базы данных. В силу исторических причин существует три базы данных: +В билде используется несколько баз данных: -- Старая - на данный момент кроме библиотеки не используется. -- Новая - основная база данных. -- Донаты - в ней хранится информация о донатах и прочее, слабо связанное с игровым процессом. +- [SurrealDB](https://surrealdb.com/docs/) - в ней хранятся данные относящиеся к геймплею и конкретному серверу, является предпочтительным способом хранения данных. +- **MySQL (Feedback)** - подключение к "feedback" базе данных, в которой хранятся баны и прочее не относящееся напрямую к геймплею. +- **MySQL (Dontaions)** - база данных связанная с донатами и в ней данные общие для всех серверов. + +## Настройка SurrealDB + +Изначально она уже настроена и ничего менять не надо, но для удобной отладки нужно запустить отдельный сервер с базой данных. + +- Установка сервера - https://surrealdb.com/docs/surrealdb/installation/ +- Установка UI - https://surrealdb.com/surrealist + +Запуск из папки с билдом: + +```sh +$ surreal start file:data/database --bind 127.0.0.1:8000 +``` + +В секции `db` конфигурации билда нужно прописать новый адрес, логин и пароль: + +```toml +[db] +address = "ws://127.0.0.1:8000" +namespace = "ss13" +login = "root" +password = "root" +``` + +Теперь можно запускать и билд и одновременно работать с базой данных через **Surrealist**. + +## Настройка MySQL В папке `sql/` содержится Docker образ и схемы двух последних баз данных: новая - `feedback`, донаты - `donations`. В продакшене каждый сервер имеет свою `feedback` базу данных, но для простоты и разработки будет достаточно одной. -## Первоначальная настройка +### Первоначальная настройка -- Необходимо установить `Docker Hub`: https://www.docker.com/get-started/ +- Необходимо установить **Docker Hub**: https://www.docker.com/get-started/ - Открыть в терминале папку с билдом: ```sh @@ -25,7 +52,7 @@ $ ./sql/Build.ps1 _Если у вас есть только bash/sh - выполняйте аналогичный файл но с расширением `.sh`_ -### Запуск +#### Запуск ```sh $ ./sql/Run.ps1 @@ -33,7 +60,7 @@ $ ./sql/Run.ps1 В консоли могут появится ошибки - не страшно, это значит что контейнер запускается в первый раз. -### Остановка +#### Остановка Остановить контейнер с MySQL вы можете через интерфейс Docker Desktop или с помощью команды: @@ -41,13 +68,13 @@ $ ./sql/Run.ps1 $ docker stop onyxdb ``` -## Конфигурация +### Конфигурация -Конфигурация базы данных расположена в файле `config/dbconfig.txt` (если нет - распакуйте из папки `config/examples`). Из этого файла билд узнаёт куда надо подключаться и с каким логином/паролем. +Конфигурация базы данных расположена в секции `db` (пример: `config/default/db.toml`). Из этого файла билд узнаёт куда надо подключаться и с каким логином/паролем. По-умолчанию конфигурация уже сделана под Docker образ и её не нужно трогать. -## Возможные проблемы +### Возможные проблемы > Как сделать себя администратором? diff --git a/flyway.conf b/flyway.conf deleted file mode 100644 index cb3b9de9951..00000000000 --- a/flyway.conf +++ /dev/null @@ -1,6 +0,0 @@ -flyway.locations=filesystem:sql/migrate - -# copy these into another file and use the -configFile switch on flyway -# flyway.url=jdbc:mysql://localhost/bs12 -# flyway.user=bs12 -# flyway.password=hunter2 diff --git a/nano/templates/art_library.tmpl b/nano/templates/art_library.tmpl index 013971abf94..34332818bda 100644 --- a/nano/templates/art_library.tmpl +++ b/nano/templates/art_library.tmpl @@ -54,8 +54,8 @@ Sort by:
- {{:helper.link("Title", null, {'sortby' : 'title'})}} - {{:helper.link("USBN", null, {'sortby' : 'id'})}} + {{:helper.link("Title", null, {'sortby' : 'title COLLATE'})}} + {{:helper.link("USBN", null, {'sortby' : 'id COLLATE'})}}
diff --git a/nano/templates/library.tmpl b/nano/templates/library.tmpl index 68061acd675..23d9fef9eca 100644 --- a/nano/templates/library.tmpl +++ b/nano/templates/library.tmpl @@ -6,19 +6,19 @@

{{:data.current_book.title}}

- Author: + Author:
{{:data.current_book.author}}
- USBN: + USBN:
{{:data.current_book.id}}
- Commands: + Commands:
{{:helper.link("Close", null, {'closebook' : 1})}} @@ -54,10 +54,10 @@ Sort by:
- {{:helper.link("Title", null, {'sortby' : 'title'})}} - {{:helper.link("Author", null, {'sortby' : 'author'})}} - {{:helper.link("Category", null, {'sortby' : 'category'})}} - {{:helper.link("USBN", null, {'sortby' : 'id'})}} + {{:helper.link("Title", null, {'sortby' : 'title COLLATE'})}} + {{:helper.link("Author", null, {'sortby' : 'author COLLATE'})}} + {{:helper.link("Category", null, {'sortby' : 'category COLLATE'})}} + {{:helper.link("USBN", null, {'sortby' : 'id NUMERIC'})}}
diff --git a/rust_g.dll b/rust_g.dll index 8af7f0802b0..5c4ece5b092 100644 Binary files a/rust_g.dll and b/rust_g.dll differ diff --git a/sql/migrate/V001_InitFeedback.sql b/sql/migrate/V001_InitFeedback.sql index c2cd7d70c5d..c56fb4c8fc8 100644 --- a/sql/migrate/V001_InitFeedback.sql +++ b/sql/migrate/V001_InitFeedback.sql @@ -257,34 +257,6 @@ CREATE TABLE IF NOT EXISTS `ip2nationCountries` ( -- Экспортируемые данные не выделены. --- Дамп структуры для таблица library -CREATE TABLE IF NOT EXISTS `library` ( - `id` int NOT NULL AUTO_INCREMENT, - `author` text NOT NULL, - `title` text NOT NULL, - `content` text NOT NULL, - `category` text NOT NULL, - `deleted` int DEFAULT NULL, - `author_ckey` text CHARACTER SET latin1 COLLATE latin1_swedish_ci, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=912 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=COMPACT; - --- Экспортируемые данные не выделены. - --- Дамп структуры для таблица library_latin1 -CREATE TABLE IF NOT EXISTS `library_latin1` ( - `id` int NOT NULL AUTO_INCREMENT, - `author` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, - `title` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, - `content` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, - `category` text CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, - `deleted` int DEFAULT NULL, - `author_ckey` text CHARACTER SET latin1 COLLATE latin1_swedish_ci, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=623 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=COMPACT; - --- Экспортируемые данные не выделены. - -- Дамп структуры для таблица old_erro_ban CREATE TABLE IF NOT EXISTS `old_erro_ban` ( `id` int NOT NULL AUTO_INCREMENT, @@ -324,24 +296,6 @@ CREATE TABLE IF NOT EXISTS `serverids` ( -- Экспортируемые данные не выделены. --- Дамп структуры для таблица whitelist -CREATE TABLE IF NOT EXISTS `whitelist` ( - `id` int NOT NULL AUTO_INCREMENT, - `ckey` text NOT NULL, - `race` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- Экспортируемые данные не выделены. - --- Дамп структуры для таблица whitelist_ckey -CREATE TABLE IF NOT EXISTS `whitelist_ckey` ( - `ckey` varchar(50) NOT NULL, - PRIMARY KEY (`ckey`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; - --- Экспортируемые данные не выделены. - -- Дамп структуры для таблица Z_buys CREATE TABLE IF NOT EXISTS `Z_buys` ( `_id` int NOT NULL AUTO_INCREMENT, diff --git a/sql/migrate/V004_ArtLibrary.sql b/sql/migrate/V004_ArtLibrary.sql deleted file mode 100644 index a4fbb3aae88..00000000000 --- a/sql/migrate/V004_ArtLibrary.sql +++ /dev/null @@ -1,10 +0,0 @@ --- Дамп структуры для таблица art_library -CREATE TABLE IF NOT EXISTS `art_library` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ckey` text NOT NULL, - `title` text NOT NULL, - `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`data`)), - `deleted` int(11) DEFAULT NULL, - `type` text DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=929 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=COMPACT;