From a7506f0aa66981858bdab29287e92bb11bce4347 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Fri, 21 Apr 2017 17:06:43 -0700 Subject: [PATCH] Add config option to completely disable karma --- code/controllers/configuration.dm | 5 + code/game/jobs/whitelist.dm | 4 + code/modules/client/client procs.dm | 294 ++++++++++++++-------------- code/modules/karma/karma.dm | 14 ++ config/example/config.txt | 7 +- 5 files changed, 176 insertions(+), 148 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index c593296c30f..6cccb48e492 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -191,6 +191,8 @@ var/shutdown_on_reboot = 0 // Whether to shut down the world instead of rebooting it + var/disable_karma = 0 // Disable all karma functions and unlock karma jobs by default + /datum/configuration/New() var/list/L = subtypesof(/datum/game_mode) for(var/T in L) @@ -593,6 +595,9 @@ if("shutdown_shell_command") shutdown_shell_command = value + if("disable_karma") + disable_karma = 1 + else diary << "Unknown setting in configuration: '[name]'" diff --git a/code/game/jobs/whitelist.dm b/code/game/jobs/whitelist.dm index 28e5a5b547c..049903b475e 100644 --- a/code/game/jobs/whitelist.dm +++ b/code/game/jobs/whitelist.dm @@ -21,6 +21,8 @@ var/list/whitelist = list() if(guest_jobbans(rank)) if(!config.usewhitelist) return 1 + if(config.disable_karma) + return 1 if(check_rights(R_ADMIN, 0, M)) return 1 if(!dbcon.IsConnected()) @@ -62,6 +64,8 @@ var/list/whitelist = list() /proc/is_alien_whitelisted(mob/M, var/species) if(!config.usealienwhitelist) return 1 + if(config.disable_karma) + return 1 if(species == "human" || species == "Human") return 1 if(check_rights(R_ADMIN, 0)) diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index f846a1613bf..faf661a8312 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -97,160 +97,163 @@ if(config && config.log_hrefs && href_logfile) to_chat(href_logfile, "[time2text(world.timeofday,"hh:mm")] [src] (usr:[usr]) || [hsrc ? "[hsrc] " : ""][href]
") - switch(href_list["karmashop"]) - if("tab") - karma_tab = text2num(href_list["tab"]) - karmashopmenu() + if(href_list["karmashop"]) + if(config.disable_karma) return - if("shop") - if(href_list["KarmaBuy"]) - var/karma=verify_karma() - switch(href_list["KarmaBuy"]) - if("1") - if(karma <5) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Barber?", "Confirmation", "No", "Yes") != "Yes") - return - DB_job_unlock("Barber",5) - return - if("2") - if(karma <5) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Brig Physician?", "Confirmation", "No", "Yes") != "Yes") - return - DB_job_unlock("Brig Physician",5) - return - if("3") - if(karma <30) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Nanotrasen Representative?", "Confirmation", "No", "Yes") != "Yes") - return - DB_job_unlock("Nanotrasen Representative",30) - return - if("5") - if(karma <30) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Blueshield?", "Confirmation", "No", "Yes") != "Yes") - return - DB_job_unlock("Blueshield",30) - return - if("6") - if(karma <30) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Mechanic?", "Confirmation", "No", "Yes") != "Yes") - return - DB_job_unlock("Mechanic",30) - return - if("7") - if(karma <45) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Magistrate?", "Confirmation", "No", "Yes") != "Yes") - return - DB_job_unlock("Magistrate",45) - return - if("9") - if(karma <30) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Security Pod Pilot?", "Confirmation", "No", "Yes") != "Yes") - return - DB_job_unlock("Security Pod Pilot",30) - return - if(href_list["KarmaBuy2"]) - var/karma=verify_karma() - switch(href_list["KarmaBuy2"]) - if("1") - if(karma <15) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Machine People?", "Confirmation", "No", "Yes") != "Yes") - return - DB_species_unlock("Machine",15) - return - if("2") - if(karma <30) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Kidan?", "Confirmation", "No", "Yes") != "Yes") - return - DB_species_unlock("Kidan",30) - return - if("3") - if(karma <30) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Grey?", "Confirmation", "No", "Yes") != "Yes") - return - DB_species_unlock("Grey",30) - return - if("4") - if(karma <45) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Vox?", "Confirmation", "No", "Yes") != "Yes") - return - DB_species_unlock("Vox",45) - return - if("5") - if(karma <45) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Slime People?", "Confirmation", "No", "Yes") != "Yes") - return - DB_species_unlock("Slime People",45) - return - if("6") - if(karma <100) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Plasmaman?", "Confirmation", "No", "Yes") != "Yes") - return - DB_species_unlock("Plasmaman",100) - return - if("7") - if(karma <30) - to_chat(usr, "You do not have enough karma!") - return - else - if(alert("Are you sure you want to unlock Drask?", "Confirmation", "No", "Yes") != "Yes") - return - DB_species_unlock("Drask",30) - return - if(href_list["KarmaRefund"]) - var/type = href_list["KarmaRefundType"] - var/job = href_list["KarmaRefund"] - var/cost = href_list["KarmaRefundCost"] - karmarefund(type,job,cost) + + switch(href_list["karmashop"]) + if("tab") + karma_tab = text2num(href_list["tab"]) + karmashopmenu() return + if("shop") + if(href_list["KarmaBuy"]) + var/karma=verify_karma() + switch(href_list["KarmaBuy"]) + if("1") + if(karma <5) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Barber?", "Confirmation", "No", "Yes") != "Yes") + return + DB_job_unlock("Barber",5) + return + if("2") + if(karma <5) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Brig Physician?", "Confirmation", "No", "Yes") != "Yes") + return + DB_job_unlock("Brig Physician",5) + return + if("3") + if(karma <30) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Nanotrasen Representative?", "Confirmation", "No", "Yes") != "Yes") + return + DB_job_unlock("Nanotrasen Representative",30) + return + if("5") + if(karma <30) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Blueshield?", "Confirmation", "No", "Yes") != "Yes") + return + DB_job_unlock("Blueshield",30) + return + if("6") + if(karma <30) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Mechanic?", "Confirmation", "No", "Yes") != "Yes") + return + DB_job_unlock("Mechanic",30) + return + if("7") + if(karma <45) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Magistrate?", "Confirmation", "No", "Yes") != "Yes") + return + DB_job_unlock("Magistrate",45) + return + if("9") + if(karma <30) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Security Pod Pilot?", "Confirmation", "No", "Yes") != "Yes") + return + DB_job_unlock("Security Pod Pilot",30) + return + if(href_list["KarmaBuy2"]) + var/karma=verify_karma() + switch(href_list["KarmaBuy2"]) + if("1") + if(karma <15) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Machine People?", "Confirmation", "No", "Yes") != "Yes") + return + DB_species_unlock("Machine",15) + return + if("2") + if(karma <30) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Kidan?", "Confirmation", "No", "Yes") != "Yes") + return + DB_species_unlock("Kidan",30) + return + if("3") + if(karma <30) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Grey?", "Confirmation", "No", "Yes") != "Yes") + return + DB_species_unlock("Grey",30) + return + if("4") + if(karma <45) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Vox?", "Confirmation", "No", "Yes") != "Yes") + return + DB_species_unlock("Vox",45) + return + if("5") + if(karma <45) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Slime People?", "Confirmation", "No", "Yes") != "Yes") + return + DB_species_unlock("Slime People",45) + return + if("6") + if(karma <100) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Plasmaman?", "Confirmation", "No", "Yes") != "Yes") + return + DB_species_unlock("Plasmaman",100) + return + if("7") + if(karma <30) + to_chat(usr, "You do not have enough karma!") + return + else + if(alert("Are you sure you want to unlock Drask?", "Confirmation", "No", "Yes") != "Yes") + return + DB_species_unlock("Drask",30) + return + if(href_list["KarmaRefund"]) + var/type = href_list["KarmaRefundType"] + var/job = href_list["KarmaRefund"] + var/cost = href_list["KarmaRefundCost"] + karmarefund(type,job,cost) + return switch(href_list["_src_"]) if("holder") hsrc = holder if("usr") hsrc = mob if("prefs") return prefs.process_link(usr,href_list) if("vars") return view_var_Topic(href,href_list,hsrc) - + //Polls and shit if(href_list["showpoll"]) - handle_player_polling() return if(href_list["createpollwindow"]) @@ -260,7 +263,6 @@ create_poll_function(href_list) return if(href_list["pollid"]) - var/pollid = href_list["pollid"] if(istext(pollid)) pollid = text2num(pollid) @@ -443,7 +445,7 @@ winset(src, null, "command=\".configure graphics-hwmode on\"") log_client_to_db(tdata) - + . = ..() //calls mob.Login() if(ckey in clientmessages) diff --git a/code/modules/karma/karma.dm b/code/modules/karma/karma.dm index bdbe222990a..81af3a38395 100644 --- a/code/modules/karma/karma.dm +++ b/code/modules/karma/karma.dm @@ -52,6 +52,9 @@ var/list/karma_spenders = list() /mob/proc/can_give_karma() if(!client) return 0 + if(config.disable_karma) + to_chat(src, "Karma is disabled.") + return 0 if(!ticker || !player_list.len || (ticker.current_state == GAME_STATE_PREGAME)) to_chat(src, "You can't award karma until the game has started.") return 0 @@ -118,6 +121,9 @@ var/list/karma_spenders = list() if(!M) to_chat(usr, "Please right click a mob to award karma directly, or use the 'Award Karma' verb to select a player from the player listing.") return + if(config.disable_karma) // this is here because someone thought it was a good idea to add an alert box before checking if they can even give a mob karma + to_chat(usr, "Karma is disabled.") + return if(alert("Give [M.name] good karma?", "Karma", "Yes", "No") != "Yes") return if(!can_give_karma_to_mob(M)) @@ -145,6 +151,10 @@ var/list/karma_spenders = list() set desc = "Reports how much karma you have accrued." set category = "OOC" + if(config.disable_karma) + to_chat(src, "Karma is disabled.") + return 0 + var/currentkarma=verify_karma() to_chat(usr, {"
You have [currentkarma] available."}) return @@ -176,6 +186,10 @@ You've gained [totalkarma] total karma in your time here.
"} set desc = "Spend your hard-earned karma here" set hidden = 1 + if(config.disable_karma) + to_chat(src, "Karma is disabled.") + return 0 + karmashopmenu() return diff --git a/config/example/config.txt b/config/example/config.txt index b1810dea483..60702180691 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -328,7 +328,7 @@ DISABLE_SPACE_RUINS ## Hub address for tracking stats ## example: Hubmakerckey.Hubname -#MEDAL_HUB_ADDRESS +#MEDAL_HUB_ADDRESS ## Password for the hub page #MEDAL_HUB_PASSWORD @@ -340,4 +340,7 @@ DISABLE_SPACE_RUINS #SHUTDOWN_ON_REBOOT ## A command to run prior to the world shutting down, only used if the above option is enabled ## This default value will kill Dream Daemon on Windows machines -#SHUTDOWN_SHELL_COMMAND taskkill /f /im dreamdaemon.exe \ No newline at end of file +#SHUTDOWN_SHELL_COMMAND taskkill /f /im dreamdaemon.exe + +## Uncomment this to disable karma and unlock all karma purchases for players by default +#DISABLE_KARMA \ No newline at end of file