From c3ec34399a6132279a6b3dc5322d9b0069b79bf1 Mon Sep 17 00:00:00 2001 From: Kyep Date: Thu, 28 Jul 2016 02:53:57 -0700 Subject: [PATCH 001/136] Initial Checkin --- SQL/paradise_schema.sql | 1 + code/controllers/configuration.dm | 9 + code/game/gamemodes/gameticker.dm | 1 + code/game/jobs/job/engineering.dm | 9 +- code/game/jobs/job/job.dm | 3 + code/game/jobs/job/medical.dm | 2 + code/game/jobs/job/science.dm | 6 + code/game/jobs/job/security.dm | 8 + code/game/jobs/job/silicon.dm | 6 +- code/game/jobs/job/supervisor.dm | 4 + code/game/jobs/job_controller.dm | 3 + code/game/jobs/job_exp.dm | 154 ++++++++++++++++++ code/modules/client/preference/preferences.dm | 4 + .../client/preference/preferences_mysql.dm | 5 +- code/modules/mob/new_player/new_player.dm | 1 + config/example/config.txt | 4 + paradise.dme | 1 + 17 files changed, 216 insertions(+), 5 deletions(-) create mode 100644 code/game/jobs/job_exp.dm diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index dd54aea2e92..9278be59503 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -250,6 +250,7 @@ CREATE TABLE `player` ( `nanoui_fancy` smallint(4) DEFAULT '1', `show_ghostitem_attack` smallint(4) DEFAULT '1', `lastchangelog` varchar(32) NOT NULL, + `exp` mediumtext DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) ) ENGINE=InnoDB AUTO_INCREMENT=32446 DEFAULT CHARSET=latin1; diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 5cedd40abfc..f8f5a68866b 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -127,6 +127,9 @@ var/use_age_restriction_for_jobs = 0 //Do jobs use account age restrictions? --requires database var/use_age_restriction_for_antags = 0 //Do antags use account age restrictions? --requires database + var/use_exp_tracking = 1 + var/use_exp_restrictions = 0 + var/simultaneous_pm_warning_timeout = 100 var/assistant_maint = 0 //Do assistants get maint access? @@ -239,6 +242,12 @@ if("use_age_restriction_for_antags") config.use_age_restriction_for_antags = 1 + if("use_exp_tracking") + config.use_exp_tracking = 1 + + if("use_exp_restrictions") + config.use_exp_restrictions = 1 + if("jobs_have_minimal_access") config.jobs_have_minimal_access = 1 diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 7d6ea9b4e7d..aef3f54af66 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -470,6 +470,7 @@ var/round_start_time = 0 if(findtext("[handler]","auto_declare_completion_")) call(mode, handler)() + update_exp(round(ROUND_TIME / 60)) scoreboard() karmareminder() diff --git a/code/game/jobs/job/engineering.dm b/code/game/jobs/job/engineering.dm index 73e3e5717d3..c13ccc93e85 100644 --- a/code/game/jobs/job/engineering.dm +++ b/code/game/jobs/job/engineering.dm @@ -17,7 +17,8 @@ access_heads, access_construction, access_sec_doors, access_ce, access_RC_announce, access_keycard_auth, access_tcomsat, access_minisat, access_mechanic, access_mineral_storeroom) minimal_player_age = 21 - + exp_requirements = 240 + exp_type = "eng" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -54,7 +55,8 @@ minimal_access = list(access_eva, access_engine, access_engine_equip, access_tech_storage, access_maint_tunnels, access_external_airlocks, access_construction) alt_titles = list("Maintenance Technician","Engine Technician","Electrician") minimal_player_age = 7 - + exp_requirements = 120 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_eng(H), slot_l_ear) @@ -89,7 +91,8 @@ minimal_access = list(access_eva, access_atmospherics, access_maint_tunnels, access_external_airlocks, access_emergency_storage, access_construction) alt_titles = list("Atmospheric Technician") minimal_player_age = 7 - + exp_requirements = 120 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_eng(H), slot_l_ear) diff --git a/code/game/jobs/job/job.dm b/code/game/jobs/job/job.dm index b8e7f44ecb4..209127d9abe 100644 --- a/code/game/jobs/job/job.dm +++ b/code/game/jobs/job/job.dm @@ -41,6 +41,9 @@ //If you have use_age_restriction_for_jobs config option enabled and the database set up, this option will add a requirement for players to be at least minimal_player_age days old. (meaning they first signed in at least that many days before.) var/minimal_player_age = 0 + var/exp_requirements = 0 + var/exp_type = "" + var/admin_only = 0 var/spawn_ert = 0 diff --git a/code/game/jobs/job/medical.dm b/code/game/jobs/job/medical.dm index a064f0247f5..4c0d54e07d6 100644 --- a/code/game/jobs/job/medical.dm +++ b/code/game/jobs/job/medical.dm @@ -15,6 +15,8 @@ access_chemistry, access_virology, access_cmo, access_surgery, access_RC_announce, access_keycard_auth, access_sec_doors, access_psychiatrist, access_maint_tunnels, access_paramedic, access_mineral_storeroom) minimal_player_age = 21 + exp_requirements = 240 + exp_type = "med" equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/science.dm b/code/game/jobs/job/science.dm index eb23d9a2427..46c99f48d5e 100644 --- a/code/game/jobs/job/science.dm +++ b/code/game/jobs/job/science.dm @@ -17,6 +17,8 @@ access_research, access_robotics, access_xenobiology, access_ai_upload, access_RC_announce, access_keycard_auth, access_tcomsat, access_gateway, access_xenoarch, access_minisat, access_maint_tunnels, access_mineral_storeroom) minimal_player_age = 21 + exp_requirements = 240 + exp_type = "sci" // All science-y guys get bonuses for maxing out their tech. required_objectives=list( @@ -55,6 +57,8 @@ minimal_access = list(access_tox, access_tox_storage, access_research, access_xenobiology, access_xenoarch, access_maint_tunnels, access_mineral_storeroom) alt_titles = list("Xenoarcheologist", "Anomalist", "Plasma Researcher", "Xenobiologist", "Chemical Researcher") minimal_player_age = 3 + exp_requirements = 240 + exp_type = "all" // All science-y guys get bonuses for maxing out their tech. required_objectives=list( @@ -91,6 +95,8 @@ minimal_access = list(access_robotics, access_tech_storage, access_morgue, access_research, access_maint_tunnels, access_mineral_storeroom) //As a job that handles so many corpses, it makes sense for them to have morgue access. alt_titles = list("Biomechanical Engineer","Mechatronic Engineer") minimal_player_age = 3 + exp_requirements = 120 + exp_type = "all" required_objectives=list( /datum/job_objective/make_cyborg, diff --git a/code/game/jobs/job/security.dm b/code/game/jobs/job/security.dm index fdf754df57f..e1b889ed75a 100644 --- a/code/game/jobs/job/security.dm +++ b/code/game/jobs/job/security.dm @@ -17,6 +17,8 @@ access_research, access_engine, access_mining, access_medical, access_construction, access_mailsorting, access_heads, access_hos, access_RC_announce, access_keycard_auth, access_gateway, access_pilot, access_weapons) minimal_player_age = 21 + exp_requirements = 240 + exp_type = "sec" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -60,6 +62,8 @@ access = list(access_security, access_sec_doors, access_brig, access_armory, access_court, access_maint_tunnels, access_morgue, access_weapons) minimal_access = list(access_security, access_sec_doors, access_brig, access_armory, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 21 + exp_requirements = 120 + exp_type = "sec" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -106,6 +110,8 @@ minimal_access = list(access_sec_doors, access_forensics_lockers, access_morgue, access_maint_tunnels, access_court, access_weapons) alt_titles = list("Forensic Technician") minimal_player_age = 14 + exp_requirements = 120 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_sec/alt(H), slot_l_ear) @@ -162,6 +168,8 @@ access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_morgue, access_weapons) minimal_access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 14 + exp_requirements = 120 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_sec/alt(H), slot_l_ear) diff --git a/code/game/jobs/job/silicon.dm b/code/game/jobs/job/silicon.dm index 7bb2b006f87..a44040b5703 100644 --- a/code/game/jobs/job/silicon.dm +++ b/code/game/jobs/job/silicon.dm @@ -8,6 +8,8 @@ supervisors = "your laws" req_admin_notify = 1 minimal_player_age = 30 + exp_requirements = 240 + exp_type = "sil" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -15,7 +17,7 @@ /datum/job/ai/is_position_available() return (empty_playable_ai_cores.len != 0) - + /datum/job/cyborg title = "Cyborg" @@ -26,6 +28,8 @@ supervisors = "your laws and the AI" //Nodrak selection_color = "#ddffdd" minimal_player_age = 21 + exp_requirements = 120 + exp_type = "all" alt_titles = list("Android", "Robot") equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job/supervisor.dm b/code/game/jobs/job/supervisor.dm index 7768cf11870..980846edc53 100644 --- a/code/game/jobs/job/supervisor.dm +++ b/code/game/jobs/job/supervisor.dm @@ -12,6 +12,8 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) access = list() //See get_access() minimal_access = list() //See get_access() minimal_player_age = 30 + exp_requirements = 240 + exp_type = "com" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/heads/captain/alt(H), slot_l_ear) @@ -59,6 +61,8 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) idtype = /obj/item/weapon/card/id/silver req_admin_notify = 1 minimal_player_age = 21 + exp_requirements = 240 + exp_type = "sup" access = list(access_security, access_sec_doors, access_brig, access_court, access_forensics_lockers, access_medical, access_engine, access_change_ids, access_ai_upload, access_eva, access_heads, access_all_personal_lockers, access_maint_tunnels, access_bar, access_janitor, access_construction, access_morgue, diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 2409bda62ba..3a556f6d2e5 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -123,6 +123,9 @@ var/global/datum/controller/occupations/job_master if(job.admin_only) // No admin positions either. continue + if(!has_exp_for_job(player, job.title)) + continue + if(jobban_isbanned(player, job.title)) Debug("GRJ isbanned failed, Player: [player], Job: [job.title]") continue diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm new file mode 100644 index 00000000000..66685c85d3f --- /dev/null +++ b/code/game/jobs/job_exp.dm @@ -0,0 +1,154 @@ + +/proc/has_exp_for_job(mob/M, rank) + var/datum/job/job = job_master.GetJob(rank) + if(!job) + return 1 + if(!job.exp_requirements || !job.exp_type) + return 1 + if(!config.use_exp_restrictions) + return 1 + if(!M.client) + return 0 + //if(check_rights(R_ADMIN, 0, M)) + // return 1 + var/list/play_records = params2list(M.client.prefs.exp) + var/my_exp = text2num(play_records[job.exp_type]) + if(my_exp >= text2num(job.exp_requirements)) + //return_text += "
[C.mob] has [my_exp] of the [job.exp_requirements] [job.exp_type] EXP required for [job.title]." + return 1 + else + return 0 + +/client/verb/check_exp() + set name = "EXP Check" + set desc = "Shows your EXP status" + set category = "EXP" + if(!establish_db_connection()) + return 0 + var/exp_text = get_exp_text(src) + to_chat(src,exp_text) + +/client/proc/get_exp_text(var/client/C) + var/return_text = "" + var/list/play_records = params2list(C.prefs.exp) + var/exp_all = text2num(play_records["all"]) + var/exp_com = play_records["com"] + var/exp_sec = play_records["sec"] + var/exp_sci = play_records["sci"] + var/exp_eng = play_records["eng"] + var/exp_med = play_records["med"] + var/exp_sup = play_records["sup"] + var/exp_sil = play_records["sil"] + var/exp_ant = play_records["ant"] + var/exp_gho = play_records["gho"] + if(play_records.len) + return_text += "General EXP: [exp_all]" + if(exp_com > 0) + return_text += "
Command EXP: [exp_com]" + if(exp_sec > 0) + return_text += "
Security EXP: [exp_sec]" + if(exp_sci > 0) + return_text += "
Science EXP: [exp_sci]" + if(exp_eng > 0) + return_text += "
Engineering EXP: [exp_eng]" + if(exp_med > 0) + return_text += "
Medical EXP: [exp_med]" + if(exp_sup > 0) + return_text += "
Support EXP: [exp_sup]" + if(exp_sil > 0) + return_text += "
Silicon EXP: [exp_sil]" + if(exp_ant > 0) + return_text += "
Antag EXP: [exp_ant]" + if(exp_gho > 0) + return_text += "
Ghost EXP: [exp_gho]" + return_text += "
Jobs" + for(var/datum/job/job in job_master.occupations) + if(job.exp_requirements && job.exp_type) + if(has_exp_for_job(C.mob, job.title)) + return_text += " | [job.title] " + else + return_text += " | [job.title] " + return(return_text) + else + return("[C.mob] has no EXP records.") + +/client/verb/add_exp() + set name = "EXP ADD" + set desc = "DEBUG" + set category = "EXP" + update_exp(25) + +/client/proc/cmd_show_exp_panel(var/mob/living/M in mob_list) + set category = "EXP" + set name = "Show EXP Panel" + set desc="" + if(!check_rights(R_ADMIN)) + return + if(M.client) + var/body = "EXP for [M.key]" + body += M.client.get_exp_text(M.client) + body += "" + usr << browse(body, "window=adminplayerexp;size=550x615") + else + to_chat(usr,"Mob [M] has no client.") + +/proc/update_exp(var/minutes) + if(!establish_db_connection()) + return -1 + + for(var/client/C in clients) + if(C.inactivity < (10 * 10 * 60)) + //var/list/play_records = params2list(C.prefs.exp) + + var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") + exp_read.Execute() + var/list/play_records = list() + while(exp_read.NextRow()) + play_records = params2list(exp_read.item[1]) + // ------------- + + for(var/rtype in list("all","com","sec","sci","eng","med","sup","sil","ant", "gho")) + if(!text2num(play_records[rtype])) + play_records[rtype] = 0 + else + play_records[rtype] = text2num(play_records[rtype]) + + if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) + play_records["all"] += minutes + to_chat(C.mob,"You got: [minutes] EXP!") + if(C.mob.mind.assigned_role in command_positions) + play_records["com"] += minutes + to_chat(C.mob,"You got: [minutes] Command EXP!") + if(C.mob.mind.assigned_role in security_positions) + play_records["sec"] += minutes + to_chat(C.mob,"You got: [minutes] Security EXP!") + if(C.mob.mind.assigned_role in science_positions) + play_records["sci"] += minutes + to_chat(C.mob,"You got: [minutes] Science EXP!") + if(C.mob.mind.assigned_role in engineering_positions) + play_records["eng"] += minutes + to_chat(C.mob,"You got: [minutes] Engineering EXP!") + if(C.mob.mind.assigned_role in medical_positions) + play_records["med"] += minutes + to_chat(C.mob,"You got: [minutes] Medical EXP!") + if(C.mob.mind.assigned_role in support_positions) + play_records["sup"] += minutes + to_chat(C.mob,"You got: [minutes] Support EXP!") + if(C.mob.mind.assigned_role in nonhuman_positions) + play_records["sil"] += minutes + to_chat(C.mob,"You got: [minutes] Silicon EXP!") + if(C.mob.mind.special_role) + play_records["ant"] += minutes + to_chat(C.mob,"You got: [minutes] Special EXP!") + else if(isobserver(C.mob)) + play_records["gho"] += minutes + to_chat(C.mob,"You got: [minutes] Ghost EXP!") + else + return + var/new_exp = list2params(play_records) + C.prefs.exp = new_exp + new_exp = sanitizeSQL(new_exp) + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") + update_query.Execute() + + diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index c28f472020d..50fd26b929c 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -84,6 +84,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts //game-preferences var/lastchangelog = "" //Saved changlog filesize to detect if there was a change + var/exp var/ooccolor = "#b82e00" var/be_special = list() //Special role selection var/UI_style = "Midnight" @@ -551,6 +552,9 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(jobban_isbanned(user, rank)) HTML += "[rank] \[BANNED]" continue + if(!has_exp_for_job(user, job.title)) + HTML += "[rank] \[TIME]" + continue if(!job.player_old_enough(user.client)) var/available_in_days = job.available_in_days(user.client) HTML += "[rank] \[IN [(available_in_days)] DAYS]" diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index f72ac076dff..6bc3722c9b7 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -13,7 +13,8 @@ volume, nanoui_fancy, show_ghostitem_attack, - lastchangelog + lastchangelog, + exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'"} ) @@ -40,6 +41,7 @@ nanoui_fancy = text2num(query.item[11]) show_ghostitem_attack = text2num(query.item[12]) lastchangelog = query.item[13] + exp = query.item[14] //Sanitize ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) @@ -54,6 +56,7 @@ nanoui_fancy = sanitize_integer(nanoui_fancy, 0, 1, initial(nanoui_fancy)) show_ghostitem_attack = sanitize_integer(show_ghostitem_attack, 0, 1, initial(show_ghostitem_attack)) lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) + exp = sanitize_text(exp, initial(exp)) return 1 /datum/preferences/proc/save_preferences(client/C) diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 383f75b757f..bc166cfe893 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -246,6 +246,7 @@ if(!is_job_whitelisted(src, rank)) return 0 if(!job.player_old_enough(src.client)) return 0 if(job.admin_only && !(check_rights(R_EVENT, 0))) return 0 + if(!has_exp_for_job(src, rank)) return 0 if(config.assistantlimit) if(job.title == "Civilian") diff --git a/config/example/config.txt b/config/example/config.txt index 2f723c704f4..be79211b249 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -17,6 +17,10 @@ JOBS_HAVE_MINIMAL_ACCESS ## you have noone older than 0 days, since noone has been logged yet. Only turn this on once you have had the database up for 30 days. #USE_AGE_RESTRICTION_FOR_JOBS +## Unhash the first to track playtime in database. Unhash the second to restrict job access based on playtime. Note: playtime is not account age, it is actual playtime on the server. Some jobs (e.g: head jobs) require playtime in their department to unlock. +#USE_EXP_TRACKING +#USE_EXP_RESTRICTIONS + ## Unhash this entry to have certain antagonist roles require your account to be at least a certain number of days old to select. You can configure the exact age requirement for different antag roles by editing special_role_times in /code/modules/client/preferences.dm. ## See USE_AGE_RESTRICTION_FOR_JOBS for more information #USE_AGE_RESTRICTION_FOR_ANTAGS diff --git a/paradise.dme b/paradise.dme index d79069d135d..249a386ea08 100644 --- a/paradise.dme +++ b/paradise.dme @@ -477,6 +477,7 @@ #include "code\game\gamemodes\xenos\xenos.dm" #include "code\game\jobs\access.dm" #include "code\game\jobs\job_controller.dm" +#include "code\game\jobs\job_exp.dm" #include "code\game\jobs\job_objective.dm" #include "code\game\jobs\jobs.dm" #include "code\game\jobs\whitelist.dm" From 8a4dc07f7037dc00beb5a0dcbfae61dcf6bccec6 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sat, 30 Jul 2016 19:58:04 -0700 Subject: [PATCH 002/136] Update 2 See PR comment --- code/controllers/configuration.dm | 12 +- code/game/gamemodes/gameticker.dm | 8 +- code/game/jobs/job/engineering.dm | 6 +- code/game/jobs/job/medical.dm | 11 +- code/game/jobs/job/science.dm | 6 +- code/game/jobs/job/security.dm | 8 +- code/game/jobs/job/silicon.dm | 4 +- code/game/jobs/job/supervisor.dm | 6 +- code/game/jobs/job_exp.dm | 225 ++++++++++++++++++++---------- code/modules/admin/admin.dm | 1 + code/modules/admin/admin_verbs.dm | 3 +- code/modules/admin/topic.dm | 6 + config/example/config.txt | 5 +- 13 files changed, 206 insertions(+), 95 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index f8f5a68866b..ae58d61b3ca 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -127,8 +127,9 @@ var/use_age_restriction_for_jobs = 0 //Do jobs use account age restrictions? --requires database var/use_age_restriction_for_antags = 0 //Do antags use account age restrictions? --requires database - var/use_exp_tracking = 1 - var/use_exp_restrictions = 0 + var/use_exp_tracking = 0 + var/use_exp_restrictions_heads = 0 + var/use_exp_restrictions_other = 0 var/simultaneous_pm_warning_timeout = 100 @@ -245,8 +246,11 @@ if("use_exp_tracking") config.use_exp_tracking = 1 - if("use_exp_restrictions") - config.use_exp_restrictions = 1 + if("use_exp_restrictions_heads") + config.use_exp_restrictions_heads = 1 + + if("use_exp_restrictions_other") + config.use_exp_restrictions_other = 1 if("jobs_have_minimal_access") config.jobs_have_minimal_access = 1 diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index aef3f54af66..0c4ded6e12d 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -67,6 +67,11 @@ var/round_start_time = 0 initialtpass = 1 votetimer() +/datum/controller/gameticker/proc/exptimer() + spawn(600) + update_exp(1,0) + exptimer() + /datum/controller/gameticker/proc/setup() //Create and announce mode if(master_mode=="secret") @@ -228,6 +233,8 @@ var/round_start_time = 0 if(config.sql_enabled) spawn(3000) statistic_cycle() // Polls population totals regularly and stores them in an SQL DB + if(config.use_exp_tracking) + exptimer() votetimer() @@ -470,7 +477,6 @@ var/round_start_time = 0 if(findtext("[handler]","auto_declare_completion_")) call(mode, handler)() - update_exp(round(ROUND_TIME / 60)) scoreboard() karmareminder() diff --git a/code/game/jobs/job/engineering.dm b/code/game/jobs/job/engineering.dm index c13ccc93e85..5a2200c7690 100644 --- a/code/game/jobs/job/engineering.dm +++ b/code/game/jobs/job/engineering.dm @@ -17,7 +17,7 @@ access_heads, access_construction, access_sec_doors, access_ce, access_RC_announce, access_keycard_auth, access_tcomsat, access_minisat, access_mechanic, access_mineral_storeroom) minimal_player_age = 21 - exp_requirements = 240 + exp_requirements = 600 exp_type = "eng" equip(var/mob/living/carbon/human/H) @@ -55,7 +55,7 @@ minimal_access = list(access_eva, access_engine, access_engine_equip, access_tech_storage, access_maint_tunnels, access_external_airlocks, access_construction) alt_titles = list("Maintenance Technician","Engine Technician","Electrician") minimal_player_age = 7 - exp_requirements = 120 + exp_requirements = 180 exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -91,7 +91,7 @@ minimal_access = list(access_eva, access_atmospherics, access_maint_tunnels, access_external_airlocks, access_emergency_storage, access_construction) alt_titles = list("Atmospheric Technician") minimal_player_age = 7 - exp_requirements = 120 + exp_requirements = 180 exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/medical.dm b/code/game/jobs/job/medical.dm index 4c0d54e07d6..8310e716d38 100644 --- a/code/game/jobs/job/medical.dm +++ b/code/game/jobs/job/medical.dm @@ -15,7 +15,7 @@ access_chemistry, access_virology, access_cmo, access_surgery, access_RC_announce, access_keycard_auth, access_sec_doors, access_psychiatrist, access_maint_tunnels, access_paramedic, access_mineral_storeroom) minimal_player_age = 21 - exp_requirements = 240 + exp_requirements = 600 exp_type = "med" equip(var/mob/living/carbon/human/H) @@ -53,6 +53,8 @@ minimal_access = list(access_medical, access_morgue, access_surgery, access_maint_tunnels) alt_titles = list("Surgeon","Nurse","Coroner") minimal_player_age = 3 + exp_requirements = 60 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -116,7 +118,8 @@ minimal_access = list(access_medical, access_chemistry, access_maint_tunnels, access_mineral_storeroom) alt_titles = list("Pharmacist","Pharmacologist") minimal_player_age = 7 - + exp_requirements = 180 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -148,6 +151,8 @@ access = list(access_medical, access_morgue, access_surgery, access_chemistry, access_virology, access_genetics, access_research, access_mineral_storeroom) minimal_access = list(access_medical, access_morgue, access_genetics, access_research, access_maint_tunnels) minimal_player_age = 3 + exp_requirements = 60 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -178,6 +183,8 @@ minimal_access = list(access_medical, access_virology, access_maint_tunnels, access_mineral_storeroom) alt_titles = list("Pathologist","Microbiologist") minimal_player_age = 7 + exp_requirements = 180 + exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/science.dm b/code/game/jobs/job/science.dm index 46c99f48d5e..cc34e92bfce 100644 --- a/code/game/jobs/job/science.dm +++ b/code/game/jobs/job/science.dm @@ -17,7 +17,7 @@ access_research, access_robotics, access_xenobiology, access_ai_upload, access_RC_announce, access_keycard_auth, access_tcomsat, access_gateway, access_xenoarch, access_minisat, access_maint_tunnels, access_mineral_storeroom) minimal_player_age = 21 - exp_requirements = 240 + exp_requirements = 600 exp_type = "sci" // All science-y guys get bonuses for maxing out their tech. @@ -57,7 +57,7 @@ minimal_access = list(access_tox, access_tox_storage, access_research, access_xenobiology, access_xenoarch, access_maint_tunnels, access_mineral_storeroom) alt_titles = list("Xenoarcheologist", "Anomalist", "Plasma Researcher", "Xenobiologist", "Chemical Researcher") minimal_player_age = 3 - exp_requirements = 240 + exp_requirements = 60 exp_type = "all" // All science-y guys get bonuses for maxing out their tech. @@ -95,7 +95,7 @@ minimal_access = list(access_robotics, access_tech_storage, access_morgue, access_research, access_maint_tunnels, access_mineral_storeroom) //As a job that handles so many corpses, it makes sense for them to have morgue access. alt_titles = list("Biomechanical Engineer","Mechatronic Engineer") minimal_player_age = 3 - exp_requirements = 120 + exp_requirements = 60 exp_type = "all" required_objectives=list( diff --git a/code/game/jobs/job/security.dm b/code/game/jobs/job/security.dm index e1b889ed75a..0466834aec0 100644 --- a/code/game/jobs/job/security.dm +++ b/code/game/jobs/job/security.dm @@ -17,7 +17,7 @@ access_research, access_engine, access_mining, access_medical, access_construction, access_mailsorting, access_heads, access_hos, access_RC_announce, access_keycard_auth, access_gateway, access_pilot, access_weapons) minimal_player_age = 21 - exp_requirements = 240 + exp_requirements = 600 exp_type = "sec" equip(var/mob/living/carbon/human/H) @@ -62,7 +62,7 @@ access = list(access_security, access_sec_doors, access_brig, access_armory, access_court, access_maint_tunnels, access_morgue, access_weapons) minimal_access = list(access_security, access_sec_doors, access_brig, access_armory, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 21 - exp_requirements = 120 + exp_requirements = 300 exp_type = "sec" equip(var/mob/living/carbon/human/H) @@ -110,7 +110,7 @@ minimal_access = list(access_sec_doors, access_forensics_lockers, access_morgue, access_maint_tunnels, access_court, access_weapons) alt_titles = list("Forensic Technician") minimal_player_age = 14 - exp_requirements = 120 + exp_requirements = 300 exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -168,7 +168,7 @@ access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_morgue, access_weapons) minimal_access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 14 - exp_requirements = 120 + exp_requirements = 300 exp_type = "all" equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/silicon.dm b/code/game/jobs/job/silicon.dm index a44040b5703..1eb62dea3da 100644 --- a/code/game/jobs/job/silicon.dm +++ b/code/game/jobs/job/silicon.dm @@ -8,7 +8,7 @@ supervisors = "your laws" req_admin_notify = 1 minimal_player_age = 30 - exp_requirements = 240 + exp_requirements = 300 exp_type = "sil" equip(var/mob/living/carbon/human/H) @@ -28,7 +28,7 @@ supervisors = "your laws and the AI" //Nodrak selection_color = "#ddffdd" minimal_player_age = 21 - exp_requirements = 120 + exp_requirements = 300 exp_type = "all" alt_titles = list("Android", "Robot") diff --git a/code/game/jobs/job/supervisor.dm b/code/game/jobs/job/supervisor.dm index 980846edc53..2462f139fc0 100644 --- a/code/game/jobs/job/supervisor.dm +++ b/code/game/jobs/job/supervisor.dm @@ -12,7 +12,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) access = list() //See get_access() minimal_access = list() //See get_access() minimal_player_age = 30 - exp_requirements = 240 + exp_requirements = 600 exp_type = "com" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -61,7 +61,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) idtype = /obj/item/weapon/card/id/silver req_admin_notify = 1 minimal_player_age = 21 - exp_requirements = 240 + exp_requirements = 600 exp_type = "sup" access = list(access_security, access_sec_doors, access_brig, access_court, access_forensics_lockers, access_medical, access_engine, access_change_ids, access_ai_upload, access_eva, access_heads, @@ -242,6 +242,8 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) minimal_access = list(access_lawyer, access_court, access_sec_doors, access_maint_tunnels) alt_titles = list("Lawyer","Public Defender") minimal_player_age = 30 + exp_requirements = 300 + exp_type = "sec" idtype = /obj/item/weapon/card/id/security equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index ddf59f576f9..ed69951652c 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -1,17 +1,75 @@ +// Player Verbs + + +/client/verb/check_exp() + set name = "EXP" + set desc = "Shows your EXP status" + set category = "Special Verbs" + //if(!establish_db_connection()) + // return 0 + var/body = "EXP for [key]
" + body += get_exp_report() + body += "" + src << browse(body, "window=playerexp;size=550x615") + + +// Admin Verbs + +/client/proc/cmd_mentor_check_player_exp() //Allows mentors / admins to determine who the newer players are. + set category = "Admin" + set name = "Check Player XP" + if(!check_rights(R_MENTOR|R_MOD|R_ADMIN)) + return + var/msg = "EXP Report
" + for(var/client/C in clients) + var/list/play_records = params2list(C.prefs.exp) + var/gen_exp_time = text2num(play_records["gen"]) + gen_exp_time = num2text(round(gen_exp_time / 60)) + "h" + msg += "
- [key_name_admin(C.mob)]: " + C.get_exp_general() + " " + if(msg != "") + src << browse(msg, "window=Player_exp_check") + + +/client/proc/cmd_show_exp_panel(var/client/C in clients) + if(!check_rights(R_MENTOR|R_MOD|R_ADMIN)) + return + var/body = "EXP for [C.key]
" + body += C.get_exp_report() + body += "" + src << browse(body, "window=playerexp;size=550x615") + + +// Debug verbs + +/client/verb/add_exp() + set name = "EXP Add" + set desc = "DEBUG" + set category = "Debug" + if(!check_rights(R_DEBUG)) + return + update_exp(60, 1) + + + +// Procs + /proc/has_exp_for_job(mob/M, rank) var/datum/job/job = job_master.GetJob(rank) if(!job) return 1 if(!job.exp_requirements || !job.exp_type) return 1 - if(!config.use_exp_restrictions) + if(!job_is_xp_locked(rank)) return 1 if(!M.client) return 0 //if(check_rights(R_ADMIN, 0, M)) // return 1 var/list/play_records = params2list(M.client.prefs.exp) + var/imm = text2num(play_records["imm"]) + if(imm) + return 1 var/my_exp = text2num(play_records[job.exp_type]) if(my_exp >= text2num(job.exp_requirements)) //return_text += "
[C.mob] has [my_exp] of the [job.exp_requirements] [job.exp_type] EXP required for [job.title]." @@ -19,83 +77,100 @@ else return 0 -/client/verb/check_exp() - set name = "EXP Check" - set desc = "Shows your EXP status" - set category = "EXP" - if(!establish_db_connection()) +/proc/job_is_xp_locked(jobtitle) + if(!config.use_exp_restrictions_heads && ((jobtitle in command_positions) || jobtitle == "AI")) return 0 - var/exp_text = get_exp_text(src) - to_chat(src,exp_text) + if(!config.use_exp_restrictions_other && !((jobtitle in command_positions) || jobtitle == "AI")) + return 0 + return 1 -/client/proc/get_exp_text(var/client/C) + +/mob/proc/get_exp_report() + if(client) + return client.get_exp_report() + else + return "[src] has no client." + +/client/proc/get_exp_report() var/return_text = "" - var/list/play_records = params2list(C.prefs.exp) - var/exp_all = text2num(play_records["all"]) - var/exp_com = play_records["com"] - var/exp_sec = play_records["sec"] - var/exp_sci = play_records["sci"] - var/exp_eng = play_records["eng"] - var/exp_med = play_records["med"] - var/exp_sup = play_records["sup"] - var/exp_sil = play_records["sil"] - var/exp_ant = play_records["ant"] - var/exp_gho = play_records["gho"] + //to_chat(src,"MARK 1 [return_text]") + var/list/play_records = params2list(prefs.exp) + var/exp_gen = text2num(play_records["gen"]) + var/exp_com = text2num(play_records["com"]) + var/exp_sec = text2num(play_records["sec"]) + var/exp_sci = text2num(play_records["sci"]) + var/exp_eng = text2num(play_records["eng"]) + var/exp_med = text2num(play_records["med"]) + var/exp_sup = text2num(play_records["sup"]) + var/exp_sil = text2num(play_records["sil"]) + var/exp_ant = text2num(play_records["ant"]) + var/exp_gho = text2num(play_records["gho"]) + var/exp_imm = text2num(play_records["imm"]) if(play_records.len) - return_text += "General EXP: [exp_all]" + //to_chat(src,"MARK 2 [return_text]") + if(exp_gen > 0) + return_text += "Experience:
- General: [exp_gen]" if(exp_com > 0) - return_text += "
Command EXP: [exp_com]" + return_text += "
- Command: [exp_com]" if(exp_sec > 0) - return_text += "
Security EXP: [exp_sec]" + return_text += "
- Security: [exp_sec]" if(exp_sci > 0) - return_text += "
Science EXP: [exp_sci]" + return_text += "
- Science: [exp_sci]" if(exp_eng > 0) - return_text += "
Engineering EXP: [exp_eng]" + return_text += "
- Engineering: [exp_eng]" if(exp_med > 0) - return_text += "
Medical EXP: [exp_med]" + return_text += "
- Medical: [exp_med]" if(exp_sup > 0) - return_text += "
Support EXP: [exp_sup]" + return_text += "
- Support: [exp_sup]" if(exp_sil > 0) - return_text += "
Silicon EXP: [exp_sil]" + return_text += "
- Silicon: [exp_sil]" if(exp_ant > 0) - return_text += "
Antag EXP: [exp_ant]" + return_text += "
- Special: [exp_ant]" if(exp_gho > 0) - return_text += "
Ghost EXP: [exp_gho]" - return_text += "
Jobs" + return_text += "
- Ghost: [exp_gho]" + if(exp_imm > 0) + return_text += "
- Grandfathered: YES" + //to_chat(src,"MARK 3 [return_text]") + var/list/jobs_locked = list() + var/list/jobs_unlocked = list() for(var/datum/job/job in job_master.occupations) if(job.exp_requirements && job.exp_type) - if(has_exp_for_job(C.mob, job.title)) - return_text += " | [job.title] " + if(!job_is_xp_locked(job.title)) + continue + else if(has_exp_for_job(mob, job.title)) + jobs_unlocked += "
- " + job.title else - return_text += " | [job.title] " - return(return_text) + jobs_locked += "
- " + job.title + " (" + play_records[job.exp_type] + " / [job.exp_requirements] [job.exp_type] EXP)" + if(jobs_unlocked.len) + return_text += "

Jobs Unlocked: " + //var/counter = 0 + for(var/text in jobs_unlocked) + //if(counter) + // return_text += "," + return_text += text + //counter++ + if(jobs_locked.len) + return_text += "

Jobs Not Unlocked: " + //counter = 0 + for(var/text in jobs_locked) + //if(counter) + // return_text += "," + return_text += text + //counter++ + //to_chat(src,"MARK 4 [return_text]") + return return_text else - return("[C.mob] has no EXP records.") + return "[src] has no EXP records." -/client/verb/add_exp() - set name = "EXP ADD" - set desc = "DEBUG" - set category = "EXP" - update_exp(25) +/client/proc/get_exp_general() + var/list/play_records = params2list(prefs.exp) + var/exp_gen = text2num(play_records["gen"]) + return num2text(round(exp_gen / 60)) + "h" -/client/proc/cmd_show_exp_panel(var/mob/living/M in mob_list) - set category = "EXP" - set name = "Show EXP Panel" - set desc="" - if(!check_rights(R_ADMIN)) - return - if(M.client) - var/body = "EXP for [M.key]" - body += M.client.get_exp_text(M.client) - body += "" - usr << browse(body, "window=adminplayerexp;size=550x615") - else - to_chat(usr,"Mob [M] has no client.") -/proc/update_exp(var/minutes) +/proc/update_exp(var/minutes, var/announce_changes = 0) if(!establish_db_connection()) return -1 - for(var/client/C in clients) if(C.inactivity < (10 MINUTES)) //var/list/play_records = params2list(C.prefs.exp) @@ -107,48 +182,56 @@ play_records = params2list(exp_read.item[1]) // ------------- - for(var/rtype in list("all","com","sec","sci","eng","med","sup","sil","ant", "gho")) + for(var/rtype in list("gen","com","sec","sci","eng","med","sup","sil","ant", "gho", "imm")) if(!text2num(play_records[rtype])) play_records[rtype] = 0 else play_records[rtype] = text2num(play_records[rtype]) if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) - play_records["all"] += minutes - to_chat(C.mob,"You got: [minutes] EXP!") + play_records["gen"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] General EXP!") if(C.mob.mind.assigned_role in command_positions) play_records["com"] += minutes - to_chat(C.mob,"You got: [minutes] Command EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Command EXP!") if(C.mob.mind.assigned_role in security_positions) play_records["sec"] += minutes - to_chat(C.mob,"You got: [minutes] Security EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Security EXP!") if(C.mob.mind.assigned_role in science_positions) play_records["sci"] += minutes - to_chat(C.mob,"You got: [minutes] Science EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Science EXP!") if(C.mob.mind.assigned_role in engineering_positions) play_records["eng"] += minutes - to_chat(C.mob,"You got: [minutes] Engineering EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Engineering EXP!") if(C.mob.mind.assigned_role in medical_positions) play_records["med"] += minutes - to_chat(C.mob,"You got: [minutes] Medical EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Medical EXP!") if(C.mob.mind.assigned_role in support_positions) play_records["sup"] += minutes - to_chat(C.mob,"You got: [minutes] Support EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Support EXP!") if(C.mob.mind.assigned_role in nonhuman_positions) play_records["sil"] += minutes - to_chat(C.mob,"You got: [minutes] Silicon EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Silicon EXP!") if(C.mob.mind.special_role) play_records["ant"] += minutes - to_chat(C.mob,"You got: [minutes] Special EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Special EXP!") else if(isobserver(C.mob)) play_records["gho"] += minutes - to_chat(C.mob,"You got: [minutes] Ghost EXP!") + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Ghost EXP!") else return var/new_exp = list2params(play_records) C.prefs.exp = new_exp new_exp = sanitizeSQL(new_exp) var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") - update_query.Execute() - - + update_query.Execute() \ No newline at end of file diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 233cc931831..101e6209ff0 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -43,6 +43,7 @@ var/global/nologevent = 0 if(M.client) body += " played by [M.client] " body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\]" + body += " XP: " + M.client.get_exp_general() + " " if(istype(M, /mob/new_player)) body += " Hasn't Entered Game " diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 90ad26039db..e4a21161ccc 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -2,7 +2,8 @@ var/list/admin_verbs_default = list( /client/proc/deadmin_self, /*destroys our own admin datum so we can play as a regular player*/ /client/proc/hide_verbs, /*hides all our adminverbs*/ - /client/proc/cmd_mentor_check_new_players + /client/proc/cmd_mentor_check_new_players, + /client/proc/cmd_mentor_check_player_exp ) var/list/admin_verbs_admin = list( /client/proc/check_antagonists, /*shows all antags*/ diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 6dacca13d12..98cef945264 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2016,6 +2016,12 @@ fax_panel(usr) + else if(href_list["getexpwindow"]) + if(!check_rights(R_MENTOR|R_MOD|R_ADMIN)) return + + var/mob/M = locate(href_list["getexpwindow"]) + usr.client.cmd_show_exp_panel(M.client) + else if(href_list["jumpto"]) if(!check_rights(R_ADMIN)) return diff --git a/config/example/config.txt b/config/example/config.txt index be79211b249..2e5e50e72bb 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -17,9 +17,10 @@ JOBS_HAVE_MINIMAL_ACCESS ## you have noone older than 0 days, since noone has been logged yet. Only turn this on once you have had the database up for 30 days. #USE_AGE_RESTRICTION_FOR_JOBS -## Unhash the first to track playtime in database. Unhash the second to restrict job access based on playtime. Note: playtime is not account age, it is actual playtime on the server. Some jobs (e.g: head jobs) require playtime in their department to unlock. +## Unhash the first to track playtime in database. Unhash the second to restrict job access based on playtime for head jobs and the AI. Unhash the second to do so for other non-civ jobs. Playtime is based on actual playtime on this server. All of these require database to be enabled. #USE_EXP_TRACKING -#USE_EXP_RESTRICTIONS +#USE_EXP_RESTRICTIONS_HEADS +#USE_EXP_RESTRICTIONS_OTHER ## Unhash this entry to have certain antagonist roles require your account to be at least a certain number of days old to select. You can configure the exact age requirement for different antag roles by editing special_role_times in /code/modules/client/preferences.dm. ## See USE_AGE_RESTRICTION_FOR_JOBS for more information From c1064c28d5d9b6264eef672354f8d95ddf85a529 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sat, 30 Jul 2016 21:42:24 -0700 Subject: [PATCH 003/136] Update 3 - Hid XP info from mentors (Fox request) - Commented the verb that lets normal players see their XP (Neca request) - Added logging for usage of admin XP verbs - Deleted old commented code - Formatted XP numbers in reports as "1h", "3h", "27h" etc rather than a # of points/minutes. --- code/game/jobs/job_exp.dm | 63 +++++++++++++++---------------- code/modules/admin/admin.dm | 4 +- code/modules/admin/admin_verbs.dm | 6 +-- 3 files changed, 35 insertions(+), 38 deletions(-) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index ed69951652c..f32b2ffce95 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -2,6 +2,8 @@ // Player Verbs +/* +// Player's "check my EXP" verb, commented by request of Neca /client/verb/check_exp() set name = "EXP" set desc = "Shows your EXP status" @@ -12,14 +14,14 @@ body += get_exp_report() body += "" src << browse(body, "window=playerexp;size=550x615") - +*/ // Admin Verbs -/client/proc/cmd_mentor_check_player_exp() //Allows mentors / admins to determine who the newer players are. +/client/proc/cmd_admin_check_player_exp() //Allows admins to determine who the newer players are. set category = "Admin" set name = "Check Player XP" - if(!check_rights(R_MENTOR|R_MOD|R_ADMIN)) + if(!check_rights(R_ADMIN)) return var/msg = "EXP Report
" for(var/client/C in clients) @@ -29,10 +31,11 @@ msg += "
- [key_name_admin(C.mob)]: " + C.get_exp_general() + " " if(msg != "") src << browse(msg, "window=Player_exp_check") - + log_admin("[key_name(usr)] checked player EXP") + feedback_add_details("admin_verb","MEXP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! /client/proc/cmd_show_exp_panel(var/client/C in clients) - if(!check_rights(R_MENTOR|R_MOD|R_ADMIN)) + if(!check_rights(R_ADMIN)) return var/body = "EXP for [C.key]
" body += C.get_exp_report() @@ -40,7 +43,7 @@ src << browse(body, "window=playerexp;size=550x615") -// Debug verbs +// Admin Debug verbs /client/verb/add_exp() set name = "EXP Add" @@ -49,7 +52,8 @@ if(!check_rights(R_DEBUG)) return update_exp(60, 1) - + log_admin("[key_name(usr)] granted player EXP") + feedback_add_details("admin_verb","GEXP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! // Procs @@ -92,8 +96,9 @@ return "[src] has no client." /client/proc/get_exp_report() + if(!config.use_exp_tracking) + return "EXP tracking is disabled in the server configuration file." var/return_text = "" - //to_chat(src,"MARK 1 [return_text]") var/list/play_records = params2list(prefs.exp) var/exp_gen = text2num(play_records["gen"]) var/exp_com = text2num(play_records["com"]) @@ -107,30 +112,28 @@ var/exp_gho = text2num(play_records["gho"]) var/exp_imm = text2num(play_records["imm"]) if(play_records.len) - //to_chat(src,"MARK 2 [return_text]") if(exp_gen > 0) - return_text += "Experience:
- General: [exp_gen]" + return_text += "Experience:
- General: " + get_exp_format(exp_gen) if(exp_com > 0) - return_text += "
- Command: [exp_com]" + return_text += "
- Command: " + get_exp_format(exp_com) if(exp_sec > 0) - return_text += "
- Security: [exp_sec]" + return_text += "
- Security: " + get_exp_format(exp_sec) if(exp_sci > 0) - return_text += "
- Science: [exp_sci]" + return_text += "
- Science: " + get_exp_format(exp_sci) if(exp_eng > 0) - return_text += "
- Engineering: [exp_eng]" + return_text += "
- Engineering: " + get_exp_format(exp_eng) if(exp_med > 0) - return_text += "
- Medical: [exp_med]" + return_text += "
- Medical: " + get_exp_format(exp_med) if(exp_sup > 0) - return_text += "
- Support: [exp_sup]" + return_text += "
- Support: " + get_exp_format(exp_sup) if(exp_sil > 0) - return_text += "
- Silicon: [exp_sil]" + return_text += "
- Silicon: " + get_exp_format(exp_sil) if(exp_ant > 0) - return_text += "
- Special: [exp_ant]" + return_text += "
- Special: " + get_exp_format(exp_ant) if(exp_gho > 0) - return_text += "
- Ghost: [exp_gho]" + return_text += "
- Ghost: " + get_exp_format(exp_gho) if(exp_imm > 0) return_text += "
- Grandfathered: YES" - //to_chat(src,"MARK 3 [return_text]") var/list/jobs_locked = list() var/list/jobs_unlocked = list() for(var/datum/job/job in job_master.occupations) @@ -140,24 +143,15 @@ else if(has_exp_for_job(mob, job.title)) jobs_unlocked += "
- " + job.title else - jobs_locked += "
- " + job.title + " (" + play_records[job.exp_type] + " / [job.exp_requirements] [job.exp_type] EXP)" + jobs_locked += "
- " + job.title + " (" + get_exp_format(text2num(play_records[job.exp_type])) + " / " + get_exp_format(job.exp_requirements) + " [job.exp_type] EXP)" if(jobs_unlocked.len) return_text += "

Jobs Unlocked: " - //var/counter = 0 for(var/text in jobs_unlocked) - //if(counter) - // return_text += "," return_text += text - //counter++ if(jobs_locked.len) return_text += "

Jobs Not Unlocked: " - //counter = 0 for(var/text in jobs_locked) - //if(counter) - // return_text += "," return_text += text - //counter++ - //to_chat(src,"MARK 4 [return_text]") return return_text else return "[src] has no EXP records." @@ -165,22 +159,25 @@ /client/proc/get_exp_general() var/list/play_records = params2list(prefs.exp) var/exp_gen = text2num(play_records["gen"]) - return num2text(round(exp_gen / 60)) + "h" + return get_exp_format(exp_gen) +/client/proc/get_exp_format(var/expnum) + if(expnum > 0) + return num2text(round(expnum / 60)) + "h" + else + return "0h" /proc/update_exp(var/minutes, var/announce_changes = 0) if(!establish_db_connection()) return -1 for(var/client/C in clients) if(C.inactivity < (10 MINUTES)) - //var/list/play_records = params2list(C.prefs.exp) var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") exp_read.Execute() var/list/play_records = list() while(exp_read.NextRow()) play_records = params2list(exp_read.item[1]) - // ------------- for(var/rtype in list("gen","com","sec","sci","eng","med","sup","sil","ant", "gho", "imm")) if(!text2num(play_records[rtype])) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 101e6209ff0..af3469e55fb 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -42,8 +42,8 @@ var/global/nologevent = 0 body += "Options panel for [M]" if(M.client) body += " played by [M.client] " - body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\]" - body += " XP: " + M.client.get_exp_general() + " " + body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\] " + body += "\[" + M.client.get_exp_general() + "\]" if(istype(M, /mob/new_player)) body += " Hasn't Entered Game " diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index e4a21161ccc..5270e4750e5 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -2,8 +2,7 @@ var/list/admin_verbs_default = list( /client/proc/deadmin_self, /*destroys our own admin datum so we can play as a regular player*/ /client/proc/hide_verbs, /*hides all our adminverbs*/ - /client/proc/cmd_mentor_check_new_players, - /client/proc/cmd_mentor_check_player_exp + /client/proc/cmd_mentor_check_new_players ) var/list/admin_verbs_admin = list( /client/proc/check_antagonists, /*shows all antags*/ @@ -75,7 +74,8 @@ var/list/admin_verbs_admin = list( /client/proc/change_human_appearance_self, /* Allows the human-based mob itself change its basic appearance */ /client/proc/debug_variables, /client/proc/show_snpc_verbs, - /client/proc/reset_all_tcs /*resets all telecomms scripts*/ + /client/proc/reset_all_tcs, /*resets all telecomms scripts*/ + /client/proc/cmd_admin_check_player_exp ) var/list/admin_verbs_ban = list( /client/proc/unban_panel, From 9d229677bf1c3c045d63cccbb81a94bc59476901 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sat, 30 Jul 2016 22:06:25 -0700 Subject: [PATCH 004/136] Adds %s to report that Neca asked for --- code/game/jobs/job_exp.dm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index f32b2ffce95..13737c60e49 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -115,23 +115,23 @@ if(exp_gen > 0) return_text += "Experience:
- General: " + get_exp_format(exp_gen) if(exp_com > 0) - return_text += "
- Command: " + get_exp_format(exp_com) + return_text += "
- Command: " + get_exp_format(exp_com) + " (" + num2text(round(exp_com/exp_gen*100)) + "%)" if(exp_sec > 0) - return_text += "
- Security: " + get_exp_format(exp_sec) + return_text += "
- Security: " + get_exp_format(exp_sec) + " (" + num2text(round(exp_sec/exp_gen*100)) + "%)" if(exp_sci > 0) - return_text += "
- Science: " + get_exp_format(exp_sci) + return_text += "
- Science: " + get_exp_format(exp_sci) + " (" + num2text(round(exp_sci/exp_gen*100)) + "%)" if(exp_eng > 0) - return_text += "
- Engineering: " + get_exp_format(exp_eng) + return_text += "
- Engineering: " + get_exp_format(exp_eng) + " (" + num2text(round(exp_eng/exp_gen*100)) + "%)" if(exp_med > 0) - return_text += "
- Medical: " + get_exp_format(exp_med) + return_text += "
- Medical: " + get_exp_format(exp_med) + " (" + num2text(round(exp_med/exp_gen*100)) + "%)" if(exp_sup > 0) - return_text += "
- Support: " + get_exp_format(exp_sup) + return_text += "
- Support: " + get_exp_format(exp_sup) + " (" + num2text(round(exp_sup/exp_gen*100)) + "%)" if(exp_sil > 0) - return_text += "
- Silicon: " + get_exp_format(exp_sil) + return_text += "
- Silicon: " + get_exp_format(exp_sil) + " (" + num2text(round(exp_sil/exp_gen*100)) + "%)" if(exp_ant > 0) - return_text += "
- Special: " + get_exp_format(exp_ant) + return_text += "
- Special: " + get_exp_format(exp_ant) + " (" + num2text(round(exp_ant/exp_gen*100)) + "%)" if(exp_gho > 0) - return_text += "
- Ghost: " + get_exp_format(exp_gho) + return_text += "
- Ghost: " + get_exp_format(exp_gho) + " (" + num2text(round(exp_gho/exp_gen*100)) + "%)" if(exp_imm > 0) return_text += "
- Grandfathered: YES" var/list/jobs_locked = list() From f590df32681e80702b33a2766f80f292a95941e0 Mon Sep 17 00:00:00 2001 From: Kyep Date: Tue, 2 Aug 2016 22:46:06 -0700 Subject: [PATCH 005/136] Tidyup - Deletes old debugging code - Deletes old test options - Deletes old comments - Changes a check from MENTOR+ to ADMIN+ - Enables the admin bypass for job permission checks --- code/game/jobs/job_exp.dm | 34 ++-------------------------------- code/modules/admin/topic.dm | 2 +- 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index 13737c60e49..f6443ab157c 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -1,20 +1,4 @@ -// Player Verbs - - -/* -// Player's "check my EXP" verb, commented by request of Neca -/client/verb/check_exp() - set name = "EXP" - set desc = "Shows your EXP status" - set category = "Special Verbs" - //if(!establish_db_connection()) - // return 0 - var/body = "EXP for [key]
" - body += get_exp_report() - body += "" - src << browse(body, "window=playerexp;size=550x615") -*/ // Admin Verbs @@ -43,19 +27,6 @@ src << browse(body, "window=playerexp;size=550x615") -// Admin Debug verbs - -/client/verb/add_exp() - set name = "EXP Add" - set desc = "DEBUG" - set category = "Debug" - if(!check_rights(R_DEBUG)) - return - update_exp(60, 1) - log_admin("[key_name(usr)] granted player EXP") - feedback_add_details("admin_verb","GEXP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! - - // Procs /proc/has_exp_for_job(mob/M, rank) @@ -68,15 +39,14 @@ return 1 if(!M.client) return 0 - //if(check_rights(R_ADMIN, 0, M)) - // return 1 + if(check_rights(R_ADMIN, 0, M)) + return 1 var/list/play_records = params2list(M.client.prefs.exp) var/imm = text2num(play_records["imm"]) if(imm) return 1 var/my_exp = text2num(play_records[job.exp_type]) if(my_exp >= text2num(job.exp_requirements)) - //return_text += "
[C.mob] has [my_exp] of the [job.exp_requirements] [job.exp_type] EXP required for [job.title]." return 1 else return 0 diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 98cef945264..51577089940 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2017,7 +2017,7 @@ fax_panel(usr) else if(href_list["getexpwindow"]) - if(!check_rights(R_MENTOR|R_MOD|R_ADMIN)) return + if(!check_rights(R_ADMIN)) return var/mob/M = locate(href_list["getexpwindow"]) usr.client.cmd_show_exp_panel(M.client) From 5f21f4a01a70ae2d4985ce4c5cce0d66f3d0516b Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 3 Aug 2016 01:08:28 -0700 Subject: [PATCH 006/136] SQL Change for install instructions --- SQL/paradise_schema.sql | 2 +- SQL/paradise_schema_prefixed.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index de48c5bba60..1e509dc8149 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -250,7 +250,7 @@ CREATE TABLE `player` ( `nanoui_fancy` smallint(4) DEFAULT '1', `show_ghostitem_attack` smallint(4) DEFAULT '1', `lastchangelog` varchar(32) NOT NULL DEFAULT '0', - `exp` mediumtext DEFAULT '', + `exp` mediumtext NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) ) ENGINE=InnoDB AUTO_INCREMENT=32446 DEFAULT CHARSET=latin1; diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index a07684cd8da..20efd87c90a 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -250,7 +250,7 @@ CREATE TABLE `SS13_player` ( `nanoui_fancy` smallint(4) DEFAULT '1', `show_ghostitem_attack` smallint(4) DEFAULT '1', `lastchangelog` varchar(32) NOT NULL DEFAULT '0', - `exp` mediumtext DEFAULT '', + `exp` mediumtext NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) ) ENGINE=InnoDB AUTO_INCREMENT=32446 DEFAULT CHARSET=latin1; From efc48c58d5a853e703b96f846a4fb762b43430e7 Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 3 Aug 2016 03:43:32 -0700 Subject: [PATCH 007/136] Krausus Updates - Eliminates recursion in exptimer(), uses spawn() and sleep() instead - Reduces frequency of updates from once every minute, to once per 5 minutes - Makes each update sleep briefly in between each DB query so it cannot hammer the server even if >100 players are connected --- code/game/gamemodes/gameticker.dm | 7 +- code/game/jobs/job_exp.dm | 120 +++++++++++++++--------------- 2 files changed, 65 insertions(+), 62 deletions(-) diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 0c4ded6e12d..254ea0cf321 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -68,9 +68,10 @@ var/round_start_time = 0 votetimer() /datum/controller/gameticker/proc/exptimer() - spawn(600) - update_exp(1,0) - exptimer() + spawn(0) + while(TRUE) + update_exp(5,0) + sleep(3000) /datum/controller/gameticker/proc/setup() //Create and announce mode diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index f6443ab157c..f789fcdb695 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -140,65 +140,67 @@ /proc/update_exp(var/minutes, var/announce_changes = 0) if(!establish_db_connection()) return -1 - for(var/client/C in clients) - if(C.inactivity < (10 MINUTES)) + spawn(0) + for(var/client/C in clients) + if(C.inactivity < (10 MINUTES)) - var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") - exp_read.Execute() - var/list/play_records = list() - while(exp_read.NextRow()) - play_records = params2list(exp_read.item[1]) + var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") + exp_read.Execute() + var/list/play_records = list() + while(exp_read.NextRow()) + play_records = params2list(exp_read.item[1]) - for(var/rtype in list("gen","com","sec","sci","eng","med","sup","sil","ant", "gho", "imm")) - if(!text2num(play_records[rtype])) - play_records[rtype] = 0 + for(var/rtype in list("gen","com","sec","sci","eng","med","sup","sil","ant", "gho", "imm")) + if(!text2num(play_records[rtype])) + play_records[rtype] = 0 + else + play_records[rtype] = text2num(play_records[rtype]) + + if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) + play_records["gen"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] General EXP!") + if(C.mob.mind.assigned_role in command_positions) + play_records["com"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Command EXP!") + if(C.mob.mind.assigned_role in security_positions) + play_records["sec"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Security EXP!") + if(C.mob.mind.assigned_role in science_positions) + play_records["sci"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Science EXP!") + if(C.mob.mind.assigned_role in engineering_positions) + play_records["eng"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Engineering EXP!") + if(C.mob.mind.assigned_role in medical_positions) + play_records["med"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Medical EXP!") + if(C.mob.mind.assigned_role in support_positions) + play_records["sup"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Support EXP!") + if(C.mob.mind.assigned_role in nonhuman_positions) + play_records["sil"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Silicon EXP!") + if(C.mob.mind.special_role) + play_records["ant"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Special EXP!") + else if(isobserver(C.mob)) + play_records["gho"] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Ghost EXP!") else - play_records[rtype] = text2num(play_records[rtype]) - - if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) - play_records["gen"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] General EXP!") - if(C.mob.mind.assigned_role in command_positions) - play_records["com"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Command EXP!") - if(C.mob.mind.assigned_role in security_positions) - play_records["sec"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Security EXP!") - if(C.mob.mind.assigned_role in science_positions) - play_records["sci"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Science EXP!") - if(C.mob.mind.assigned_role in engineering_positions) - play_records["eng"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Engineering EXP!") - if(C.mob.mind.assigned_role in medical_positions) - play_records["med"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Medical EXP!") - if(C.mob.mind.assigned_role in support_positions) - play_records["sup"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Support EXP!") - if(C.mob.mind.assigned_role in nonhuman_positions) - play_records["sil"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Silicon EXP!") - if(C.mob.mind.special_role) - play_records["ant"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Special EXP!") - else if(isobserver(C.mob)) - play_records["gho"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Ghost EXP!") - else - return - var/new_exp = list2params(play_records) - C.prefs.exp = new_exp - new_exp = sanitizeSQL(new_exp) - var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") - update_query.Execute() \ No newline at end of file + return + var/new_exp = list2params(play_records) + C.prefs.exp = new_exp + new_exp = sanitizeSQL(new_exp) + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") + update_query.Execute() + sleep(10) \ No newline at end of file From ee63b91db97999b9a237d73f752bfaafaa0605c4 Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 3 Aug 2016 03:44:39 -0700 Subject: [PATCH 008/136] 3000 -> 5 MINUTES --- code/game/gamemodes/gameticker.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 254ea0cf321..26c037fe7f5 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -71,7 +71,7 @@ var/round_start_time = 0 spawn(0) while(TRUE) update_exp(5,0) - sleep(3000) + sleep(5 MINUTES) /datum/controller/gameticker/proc/setup() //Create and announce mode From bf57c32a1077ce5d0a4afb8392d51556881d0c76 Mon Sep 17 00:00:00 2001 From: Kyep Date: Thu, 4 Aug 2016 00:38:27 -0700 Subject: [PATCH 009/136] Cleanup - Replaced 'EXP' with "Playtime' in most admin-visible locations. The system is still invisible to normal players. - Changed the types of exp you can accumulate from 'all', 'eng', 'sup', etc to more human-friendly names like 'Crew', 'Engineering', and 'Supply'. - Eliminated some copy-paste. - Added a new configuration option: use_exp_restrictions_heads_hours. When enabled and set to a >0 value, it overrides all head/ai job playtime requirements, instead substituting that number of hours. --- code/controllers/configuration.dm | 4 + code/game/jobs/job/engineering.dm | 6 +- code/game/jobs/job/medical.dm | 10 +- code/game/jobs/job/science.dm | 6 +- code/game/jobs/job/security.dm | 8 +- code/game/jobs/job/silicon.dm | 4 +- code/game/jobs/job/supervisor.dm | 6 +- code/game/jobs/job_exp.dm | 205 ++++++++++++++---------------- code/modules/admin/admin.dm | 2 +- code/modules/admin/admin_verbs.dm | 2 +- code/modules/admin/topic.dm | 4 +- config/example/config.txt | 5 +- 12 files changed, 130 insertions(+), 132 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index ae58d61b3ca..a72563541d5 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -129,6 +129,7 @@ var/use_exp_tracking = 0 var/use_exp_restrictions_heads = 0 + var/use_exp_restrictions_heads_hours = 0 var/use_exp_restrictions_other = 0 var/simultaneous_pm_warning_timeout = 100 @@ -249,6 +250,9 @@ if("use_exp_restrictions_heads") config.use_exp_restrictions_heads = 1 + if("use_exp_restrictions_heads_hours") + config.use_exp_restrictions_heads_hours = value + if("use_exp_restrictions_other") config.use_exp_restrictions_other = 1 diff --git a/code/game/jobs/job/engineering.dm b/code/game/jobs/job/engineering.dm index 5a2200c7690..3e42c3daa32 100644 --- a/code/game/jobs/job/engineering.dm +++ b/code/game/jobs/job/engineering.dm @@ -18,7 +18,7 @@ access_ce, access_RC_announce, access_keycard_auth, access_tcomsat, access_minisat, access_mechanic, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = "eng" + exp_type = "Engineering" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -56,7 +56,7 @@ alt_titles = list("Maintenance Technician","Engine Technician","Electrician") minimal_player_age = 7 exp_requirements = 180 - exp_type = "all" + exp_type = "Crew" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_eng(H), slot_l_ear) @@ -92,7 +92,7 @@ alt_titles = list("Atmospheric Technician") minimal_player_age = 7 exp_requirements = 180 - exp_type = "all" + exp_type = "Crew" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_eng(H), slot_l_ear) diff --git a/code/game/jobs/job/medical.dm b/code/game/jobs/job/medical.dm index 8310e716d38..b27bc4586be 100644 --- a/code/game/jobs/job/medical.dm +++ b/code/game/jobs/job/medical.dm @@ -16,7 +16,7 @@ access_keycard_auth, access_sec_doors, access_psychiatrist, access_maint_tunnels, access_paramedic, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = "med" + exp_type = "Medical" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -54,7 +54,7 @@ alt_titles = list("Surgeon","Nurse","Coroner") minimal_player_age = 3 exp_requirements = 60 - exp_type = "all" + exp_type = "Crew" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -119,7 +119,7 @@ alt_titles = list("Pharmacist","Pharmacologist") minimal_player_age = 7 exp_requirements = 180 - exp_type = "all" + exp_type = "Crew" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -152,7 +152,7 @@ minimal_access = list(access_medical, access_morgue, access_genetics, access_research, access_maint_tunnels) minimal_player_age = 3 exp_requirements = 60 - exp_type = "all" + exp_type = "Crew" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -184,7 +184,7 @@ alt_titles = list("Pathologist","Microbiologist") minimal_player_age = 7 exp_requirements = 180 - exp_type = "all" + exp_type = "Crew" equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/science.dm b/code/game/jobs/job/science.dm index cc34e92bfce..5f9c0b94103 100644 --- a/code/game/jobs/job/science.dm +++ b/code/game/jobs/job/science.dm @@ -18,7 +18,7 @@ access_RC_announce, access_keycard_auth, access_tcomsat, access_gateway, access_xenoarch, access_minisat, access_maint_tunnels, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = "sci" + exp_type = "Science" // All science-y guys get bonuses for maxing out their tech. required_objectives=list( @@ -58,7 +58,7 @@ alt_titles = list("Xenoarcheologist", "Anomalist", "Plasma Researcher", "Xenobiologist", "Chemical Researcher") minimal_player_age = 3 exp_requirements = 60 - exp_type = "all" + exp_type = "Crew" // All science-y guys get bonuses for maxing out their tech. required_objectives=list( @@ -96,7 +96,7 @@ alt_titles = list("Biomechanical Engineer","Mechatronic Engineer") minimal_player_age = 3 exp_requirements = 60 - exp_type = "all" + exp_type = "Crew" required_objectives=list( /datum/job_objective/make_cyborg, diff --git a/code/game/jobs/job/security.dm b/code/game/jobs/job/security.dm index 0466834aec0..d13c38d0548 100644 --- a/code/game/jobs/job/security.dm +++ b/code/game/jobs/job/security.dm @@ -18,7 +18,7 @@ access_heads, access_hos, access_RC_announce, access_keycard_auth, access_gateway, access_pilot, access_weapons) minimal_player_age = 21 exp_requirements = 600 - exp_type = "sec" + exp_type = "Security" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -63,7 +63,7 @@ minimal_access = list(access_security, access_sec_doors, access_brig, access_armory, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 21 exp_requirements = 300 - exp_type = "sec" + exp_type = "Security" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -111,7 +111,7 @@ alt_titles = list("Forensic Technician") minimal_player_age = 14 exp_requirements = 300 - exp_type = "all" + exp_type = "Crew" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_sec/alt(H), slot_l_ear) @@ -169,7 +169,7 @@ minimal_access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 14 exp_requirements = 300 - exp_type = "all" + exp_type = "Crew" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_sec/alt(H), slot_l_ear) diff --git a/code/game/jobs/job/silicon.dm b/code/game/jobs/job/silicon.dm index 1eb62dea3da..41d6cb974e7 100644 --- a/code/game/jobs/job/silicon.dm +++ b/code/game/jobs/job/silicon.dm @@ -9,7 +9,7 @@ req_admin_notify = 1 minimal_player_age = 30 exp_requirements = 300 - exp_type = "sil" + exp_type = "Silicon" equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -29,7 +29,7 @@ selection_color = "#ddffdd" minimal_player_age = 21 exp_requirements = 300 - exp_type = "all" + exp_type = "Crew" alt_titles = list("Android", "Robot") equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job/supervisor.dm b/code/game/jobs/job/supervisor.dm index 2462f139fc0..4ee2720162c 100644 --- a/code/game/jobs/job/supervisor.dm +++ b/code/game/jobs/job/supervisor.dm @@ -13,7 +13,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) minimal_access = list() //See get_access() minimal_player_age = 30 exp_requirements = 600 - exp_type = "com" + exp_type = "Command" equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/heads/captain/alt(H), slot_l_ear) @@ -62,7 +62,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) req_admin_notify = 1 minimal_player_age = 21 exp_requirements = 600 - exp_type = "sup" + exp_type = "Supply" access = list(access_security, access_sec_doors, access_brig, access_court, access_forensics_lockers, access_medical, access_engine, access_change_ids, access_ai_upload, access_eva, access_heads, access_all_personal_lockers, access_maint_tunnels, access_bar, access_janitor, access_construction, access_morgue, @@ -243,7 +243,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) alt_titles = list("Lawyer","Public Defender") minimal_player_age = 30 exp_requirements = 300 - exp_type = "sec" + exp_type = "Security" idtype = /obj/item/weapon/card/id/security equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index f789fcdb695..535da5303d4 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -1,30 +1,49 @@ +// Globals, Defines, Etc + +var/global/list/exp_jobsmap = list( + "Crew" = list(), // all playtime from all jobs, together + "Command" = list(titles = command_positions), + "Engineering" = list(titles = engineering_positions), + "Security" = list(titles = security_positions), + "Silicon" = list(titles = nonhuman_positions), + "Service" = list(titles = service_positions), + "Medical" = list(titles = medical_positions), + "Science" = list(titles = science_positions), + "Supply" = list(titles = supply_positions), + "Special" = list(), // special_role + "Ghost" = list(), // dead/observer + "Exempt" = list() // special grandfather setting +) + // Admin Verbs + /client/proc/cmd_admin_check_player_exp() //Allows admins to determine who the newer players are. set category = "Admin" - set name = "Check Player XP" + set name = "Check Player Playtime" if(!check_rights(R_ADMIN)) return - var/msg = "EXP Report
" + var/msg = "Playtime Report
Playtime:
" for(var/client/C in clients) var/list/play_records = params2list(C.prefs.exp) - var/gen_exp_time = text2num(play_records["gen"]) + var/gen_exp_time = text2num(play_records["Crew"]) gen_exp_time = num2text(round(gen_exp_time / 60)) + "h" - msg += "
- [key_name_admin(C.mob)]: " + C.get_exp_general() + " " + msg += "
- [key_name_admin(C.mob)]: " + C.get_exp_general() + " " if(msg != "") - src << browse(msg, "window=Player_exp_check") - log_admin("[key_name(usr)] checked player EXP") - feedback_add_details("admin_verb","MEXP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + src << browse(msg, "window=Player_playtime_check") + log_admin("[key_name(usr)] checked player playtime") + feedback_add_details("admin_verb","MCPP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + /client/proc/cmd_show_exp_panel(var/client/C in clients) if(!check_rights(R_ADMIN)) return - var/body = "EXP for [C.key]
" + var/body = "Playtime for [C.key]
Playtime:" body += C.get_exp_report() body += "" - src << browse(body, "window=playerexp;size=550x615") + src << browse(body, "window=playerplaytime;size=550x615") // Procs @@ -42,11 +61,14 @@ if(check_rights(R_ADMIN, 0, M)) return 1 var/list/play_records = params2list(M.client.prefs.exp) - var/imm = text2num(play_records["imm"]) - if(imm) + var/isexempt = text2num(play_records["Exempt"]) + if(isexempt) return 1 var/my_exp = text2num(play_records[job.exp_type]) - if(my_exp >= text2num(job.exp_requirements)) + var/job_requirement = text2num(job.exp_requirements) + if(config.use_exp_restrictions_heads_hours && ((rank in command_positions) || rank == "AI")) + job_requirement = text2num(config.use_exp_restrictions_heads_hours) * 60 + if(my_exp >= job_requirement) return 1 else return 0 @@ -67,68 +89,55 @@ /client/proc/get_exp_report() if(!config.use_exp_tracking) - return "EXP tracking is disabled in the server configuration file." - var/return_text = "" + return "Tracking is disabled in the server configuration file." + var/list/play_records = params2list(prefs.exp) - var/exp_gen = text2num(play_records["gen"]) - var/exp_com = text2num(play_records["com"]) - var/exp_sec = text2num(play_records["sec"]) - var/exp_sci = text2num(play_records["sci"]) - var/exp_eng = text2num(play_records["eng"]) - var/exp_med = text2num(play_records["med"]) - var/exp_sup = text2num(play_records["sup"]) - var/exp_sil = text2num(play_records["sil"]) - var/exp_ant = text2num(play_records["ant"]) - var/exp_gho = text2num(play_records["gho"]) - var/exp_imm = text2num(play_records["imm"]) - if(play_records.len) - if(exp_gen > 0) - return_text += "Experience:
- General: " + get_exp_format(exp_gen) - if(exp_com > 0) - return_text += "
- Command: " + get_exp_format(exp_com) + " (" + num2text(round(exp_com/exp_gen*100)) + "%)" - if(exp_sec > 0) - return_text += "
- Security: " + get_exp_format(exp_sec) + " (" + num2text(round(exp_sec/exp_gen*100)) + "%)" - if(exp_sci > 0) - return_text += "
- Science: " + get_exp_format(exp_sci) + " (" + num2text(round(exp_sci/exp_gen*100)) + "%)" - if(exp_eng > 0) - return_text += "
- Engineering: " + get_exp_format(exp_eng) + " (" + num2text(round(exp_eng/exp_gen*100)) + "%)" - if(exp_med > 0) - return_text += "
- Medical: " + get_exp_format(exp_med) + " (" + num2text(round(exp_med/exp_gen*100)) + "%)" - if(exp_sup > 0) - return_text += "
- Support: " + get_exp_format(exp_sup) + " (" + num2text(round(exp_sup/exp_gen*100)) + "%)" - if(exp_sil > 0) - return_text += "
- Silicon: " + get_exp_format(exp_sil) + " (" + num2text(round(exp_sil/exp_gen*100)) + "%)" - if(exp_ant > 0) - return_text += "
- Special: " + get_exp_format(exp_ant) + " (" + num2text(round(exp_ant/exp_gen*100)) + "%)" - if(exp_gho > 0) - return_text += "
- Ghost: " + get_exp_format(exp_gho) + " (" + num2text(round(exp_gho/exp_gen*100)) + "%)" - if(exp_imm > 0) - return_text += "
- Grandfathered: YES" - var/list/jobs_locked = list() - var/list/jobs_unlocked = list() - for(var/datum/job/job in job_master.occupations) - if(job.exp_requirements && job.exp_type) - if(!job_is_xp_locked(job.title)) - continue - else if(has_exp_for_job(mob, job.title)) - jobs_unlocked += "
- " + job.title - else - jobs_locked += "
- " + job.title + " (" + get_exp_format(text2num(play_records[job.exp_type])) + " / " + get_exp_format(job.exp_requirements) + " [job.exp_type] EXP)" - if(jobs_unlocked.len) - return_text += "

Jobs Unlocked: " - for(var/text in jobs_unlocked) - return_text += text - if(jobs_locked.len) - return_text += "

Jobs Not Unlocked: " - for(var/text in jobs_locked) - return_text += text - return return_text - else - return "[src] has no EXP records." + if(!play_records.len) + return "[src] has no records." + + var/return_text = "" + + var/list/exp_data = list() + for(var/cat in exp_jobsmap) + if(text2num(play_records[cat])) + exp_data[cat] = text2num(play_records[cat]) + else + exp_data[cat] = 0 + + for(var/dep in exp_data) + if(exp_data[dep] > 0) + if(dep == "Exempt") + return_text += "
- Exempt (all jobs auto-unlocked)" + else + return_text += "
- [dep] " + get_exp_format(exp_data[dep]) + " (" + num2text(round(exp_data[dep]/exp_data["Crew"]*100)) + "%)" + + var/list/jobs_locked = list() + var/list/jobs_unlocked = list() + for(var/datum/job/job in job_master.occupations) + if(job.exp_requirements && job.exp_type) + if(!job_is_xp_locked(job.title)) + continue + else if(has_exp_for_job(mob, job.title)) + jobs_unlocked += "
- " + job.title + else + var/xp_req = job.exp_requirements + if(config.use_exp_restrictions_heads_hours && ((job.title in command_positions) || job.title == "AI")) + xp_req = text2num(config.use_exp_restrictions_heads_hours) * 60 + jobs_locked += "
- " + job.title + " (" + get_exp_format(text2num(play_records[job.exp_type])) + " / " + get_exp_format(xp_req) + " [job.exp_type] EXP)" + if(jobs_unlocked.len) + return_text += "

Jobs Unlocked: " + for(var/text in jobs_unlocked) + return_text += text + if(jobs_locked.len) + return_text += "

Jobs Not Unlocked: " + for(var/text in jobs_locked) + return_text += text + return return_text + /client/proc/get_exp_general() var/list/play_records = params2list(prefs.exp) - var/exp_gen = text2num(play_records["gen"]) + var/exp_gen = text2num(play_records["Crew"]) return get_exp_format(exp_gen) /client/proc/get_exp_format(var/expnum) @@ -146,54 +155,36 @@ var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") exp_read.Execute() - var/list/play_records = list() + var/list/read_records = list() while(exp_read.NextRow()) - play_records = params2list(exp_read.item[1]) + read_records = params2list(exp_read.item[1]) - for(var/rtype in list("gen","com","sec","sci","eng","med","sup","sil","ant", "gho", "imm")) - if(!text2num(play_records[rtype])) - play_records[rtype] = 0 + var/list/play_records = list() + for(var/rtype in exp_jobsmap) + if(text2num(read_records[rtype])) + play_records[rtype] = text2num(read_records[rtype]) else - play_records[rtype] = text2num(play_records[rtype]) + play_records[rtype] = 0 if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) - play_records["gen"] += minutes + play_records["Crew"] += minutes if(announce_changes) to_chat(C.mob,"You got: [minutes] General EXP!") - if(C.mob.mind.assigned_role in command_positions) - play_records["com"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Command EXP!") - if(C.mob.mind.assigned_role in security_positions) - play_records["sec"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Security EXP!") - if(C.mob.mind.assigned_role in science_positions) - play_records["sci"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Science EXP!") - if(C.mob.mind.assigned_role in engineering_positions) - play_records["eng"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Engineering EXP!") - if(C.mob.mind.assigned_role in medical_positions) - play_records["med"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Medical EXP!") - if(C.mob.mind.assigned_role in support_positions) - play_records["sup"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Support EXP!") - if(C.mob.mind.assigned_role in nonhuman_positions) - play_records["sil"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Silicon EXP!") + + for(var/cat in exp_jobsmap) + if(exp_jobsmap[cat]["titles"]) + if(C.mob.mind.assigned_role in exp_jobsmap[cat]["titles"]) + play_records[cat] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] [cat] EXP!") + if(C.mob.mind.special_role) - play_records["ant"] += minutes + play_records["Special"] += minutes if(announce_changes) to_chat(C.mob,"You got: [minutes] Special EXP!") + else if(isobserver(C.mob)) - play_records["gho"] += minutes + play_records["Ghost"] += minutes if(announce_changes) to_chat(C.mob,"You got: [minutes] Ghost EXP!") else diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index af3469e55fb..f0faa025854 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -43,7 +43,7 @@ var/global/nologevent = 0 if(M.client) body += " played by [M.client] " body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\] " - body += "\[" + M.client.get_exp_general() + "\]" + body += "\[" + M.client.get_exp_general() + "\]" if(istype(M, /mob/new_player)) body += " Hasn't Entered Game " diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 5270e4750e5..d71b4ca690e 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -75,7 +75,7 @@ var/list/admin_verbs_admin = list( /client/proc/debug_variables, /client/proc/show_snpc_verbs, /client/proc/reset_all_tcs, /*resets all telecomms scripts*/ - /client/proc/cmd_admin_check_player_exp + /client/proc/cmd_admin_check_player_exp /* shows players by playtime */ ) var/list/admin_verbs_ban = list( /client/proc/unban_panel, diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 51577089940..a32da447050 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2016,10 +2016,10 @@ fax_panel(usr) - else if(href_list["getexpwindow"]) + else if(href_list["getplaytimewindow"]) if(!check_rights(R_ADMIN)) return - var/mob/M = locate(href_list["getexpwindow"]) + var/mob/M = locate(href_list["getplaytimewindow"]) usr.client.cmd_show_exp_panel(M.client) else if(href_list["jumpto"]) diff --git a/config/example/config.txt b/config/example/config.txt index 2e5e50e72bb..350c59b079d 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -17,9 +17,12 @@ JOBS_HAVE_MINIMAL_ACCESS ## you have noone older than 0 days, since noone has been logged yet. Only turn this on once you have had the database up for 30 days. #USE_AGE_RESTRICTION_FOR_JOBS -## Unhash the first to track playtime in database. Unhash the second to restrict job access based on playtime for head jobs and the AI. Unhash the second to do so for other non-civ jobs. Playtime is based on actual playtime on this server. All of these require database to be enabled. +## USE_EXP_TRACKING enables playtime/exp tracking. REQUIRES DATABASE TO BE ENABLED. +## USE_EXP_RESTRICTIONS_HEADS enables playtime/exp requirements for head jobs. If USE_EXP_RESTRICTIONS_HEADS_HOURS is enabled also, it uses that value for their time requirements. If not, it goes by the values defined on their job definitions in code. +## USE_EXP_RESTRICTIONS_OTHER enables playtime/exp requirements for some dangerous non-head jobs, like engineer, scientist, security officer, etc. The requirements for these jobs are always taken from code. #USE_EXP_TRACKING #USE_EXP_RESTRICTIONS_HEADS +#USE_EXP_RESTRICTIONS_HEADS_HOURS 15 #USE_EXP_RESTRICTIONS_OTHER ## Unhash this entry to have certain antagonist roles require your account to be at least a certain number of days old to select. You can configure the exact age requirement for different antag roles by editing special_role_times in /code/modules/client/preferences.dm. From ab3bb8e4b7c14468b4516634a413b454008a8f21 Mon Sep 17 00:00:00 2001 From: Kyep Date: Fri, 5 Aug 2016 01:12:34 -0700 Subject: [PATCH 010/136] Update 5 - Made use_exp_restrictions_heads_hours text2num'ed in configuration.dm, rather than on use - Converted all exp_types to #defines, instead of magic strings - Moved exp_jobsmap to jobs.dm - Replaced has_exp_for_job with job.available_in_playtime, which returns - Changed
-s to
  • s, for proper HTML lists - Made update_exp less indented, easier to read - Fixed potential runtime in admin/topic.dm when calling exp window on a non-existent mob - Made job preferences screen tell you how long until you unlock each locked job, in hours or minutes as appliccable - Changed SQL storage format because mediumtext does not support default '' - Converted exptimer() into a roundstart hook proc Missed body tag Typo fix --- SQL/paradise_schema.sql | 2 +- SQL/paradise_schema_prefixed.sql | 2 +- code/controllers/configuration.dm | 2 +- code/game/gamemodes/gameticker.dm | 8 - code/game/jobs/job/engineering.dm | 6 +- code/game/jobs/job/medical.dm | 10 +- code/game/jobs/job/science.dm | 6 +- code/game/jobs/job/security.dm | 6 +- code/game/jobs/job/silicon.dm | 4 +- code/game/jobs/job/supervisor.dm | 6 +- code/game/jobs/job_controller.dm | 2 +- code/game/jobs/job_exp.dm | 214 +++++++++--------- code/game/jobs/jobs.dm | 14 ++ code/modules/admin/topic.dm | 3 +- code/modules/client/preference/preferences.dm | 5 +- code/modules/mob/new_player/new_player.dm | 2 +- 16 files changed, 155 insertions(+), 137 deletions(-) diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index 1e509dc8149..eb9c08af9ea 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -250,7 +250,7 @@ CREATE TABLE `player` ( `nanoui_fancy` smallint(4) DEFAULT '1', `show_ghostitem_attack` smallint(4) DEFAULT '1', `lastchangelog` varchar(32) NOT NULL DEFAULT '0', - `exp` mediumtext NOT NULL DEFAULT '', + `exp` mediumtext, PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) ) ENGINE=InnoDB AUTO_INCREMENT=32446 DEFAULT CHARSET=latin1; diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index 20efd87c90a..802c3fd352b 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -250,7 +250,7 @@ CREATE TABLE `SS13_player` ( `nanoui_fancy` smallint(4) DEFAULT '1', `show_ghostitem_attack` smallint(4) DEFAULT '1', `lastchangelog` varchar(32) NOT NULL DEFAULT '0', - `exp` mediumtext NOT NULL DEFAULT '', + `exp` mediumtext, PRIMARY KEY (`id`), UNIQUE KEY `ckey` (`ckey`) ) ENGINE=InnoDB AUTO_INCREMENT=32446 DEFAULT CHARSET=latin1; diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index a72563541d5..c3779ab095d 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -251,7 +251,7 @@ config.use_exp_restrictions_heads = 1 if("use_exp_restrictions_heads_hours") - config.use_exp_restrictions_heads_hours = value + config.use_exp_restrictions_heads_hours = text2num(value) if("use_exp_restrictions_other") config.use_exp_restrictions_other = 1 diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 26c037fe7f5..7d6ea9b4e7d 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -67,12 +67,6 @@ var/round_start_time = 0 initialtpass = 1 votetimer() -/datum/controller/gameticker/proc/exptimer() - spawn(0) - while(TRUE) - update_exp(5,0) - sleep(5 MINUTES) - /datum/controller/gameticker/proc/setup() //Create and announce mode if(master_mode=="secret") @@ -234,8 +228,6 @@ var/round_start_time = 0 if(config.sql_enabled) spawn(3000) statistic_cycle() // Polls population totals regularly and stores them in an SQL DB - if(config.use_exp_tracking) - exptimer() votetimer() diff --git a/code/game/jobs/job/engineering.dm b/code/game/jobs/job/engineering.dm index 3e42c3daa32..dd88a6496ab 100644 --- a/code/game/jobs/job/engineering.dm +++ b/code/game/jobs/job/engineering.dm @@ -18,7 +18,7 @@ access_ce, access_RC_announce, access_keycard_auth, access_tcomsat, access_minisat, access_mechanic, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = "Engineering" + exp_type = EXP_TYPE_ENGINEERING equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -56,7 +56,7 @@ alt_titles = list("Maintenance Technician","Engine Technician","Electrician") minimal_player_age = 7 exp_requirements = 180 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_eng(H), slot_l_ear) @@ -92,7 +92,7 @@ alt_titles = list("Atmospheric Technician") minimal_player_age = 7 exp_requirements = 180 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_eng(H), slot_l_ear) diff --git a/code/game/jobs/job/medical.dm b/code/game/jobs/job/medical.dm index b27bc4586be..d623a79a3d1 100644 --- a/code/game/jobs/job/medical.dm +++ b/code/game/jobs/job/medical.dm @@ -16,7 +16,7 @@ access_keycard_auth, access_sec_doors, access_psychiatrist, access_maint_tunnels, access_paramedic, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = "Medical" + exp_type = EXP_TYPE_MEDICAL equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -54,7 +54,7 @@ alt_titles = list("Surgeon","Nurse","Coroner") minimal_player_age = 3 exp_requirements = 60 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -119,7 +119,7 @@ alt_titles = list("Pharmacist","Pharmacologist") minimal_player_age = 7 exp_requirements = 180 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -152,7 +152,7 @@ minimal_access = list(access_medical, access_morgue, access_genetics, access_research, access_maint_tunnels) minimal_player_age = 3 exp_requirements = 60 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -184,7 +184,7 @@ alt_titles = list("Pathologist","Microbiologist") minimal_player_age = 7 exp_requirements = 180 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/science.dm b/code/game/jobs/job/science.dm index 5f9c0b94103..090b6a2adef 100644 --- a/code/game/jobs/job/science.dm +++ b/code/game/jobs/job/science.dm @@ -18,7 +18,7 @@ access_RC_announce, access_keycard_auth, access_tcomsat, access_gateway, access_xenoarch, access_minisat, access_maint_tunnels, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = "Science" + exp_type = EXP_TYPE_SCIENCE // All science-y guys get bonuses for maxing out their tech. required_objectives=list( @@ -58,7 +58,7 @@ alt_titles = list("Xenoarcheologist", "Anomalist", "Plasma Researcher", "Xenobiologist", "Chemical Researcher") minimal_player_age = 3 exp_requirements = 60 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW // All science-y guys get bonuses for maxing out their tech. required_objectives=list( @@ -96,7 +96,7 @@ alt_titles = list("Biomechanical Engineer","Mechatronic Engineer") minimal_player_age = 3 exp_requirements = 60 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW required_objectives=list( /datum/job_objective/make_cyborg, diff --git a/code/game/jobs/job/security.dm b/code/game/jobs/job/security.dm index d13c38d0548..22661bcb35b 100644 --- a/code/game/jobs/job/security.dm +++ b/code/game/jobs/job/security.dm @@ -18,7 +18,7 @@ access_heads, access_hos, access_RC_announce, access_keycard_auth, access_gateway, access_pilot, access_weapons) minimal_player_age = 21 exp_requirements = 600 - exp_type = "Security" + exp_type = EXP_TYPE_SECURITY equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -111,7 +111,7 @@ alt_titles = list("Forensic Technician") minimal_player_age = 14 exp_requirements = 300 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_sec/alt(H), slot_l_ear) @@ -169,7 +169,7 @@ minimal_access = list(access_security, access_sec_doors, access_brig, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 14 exp_requirements = 300 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/headset_sec/alt(H), slot_l_ear) diff --git a/code/game/jobs/job/silicon.dm b/code/game/jobs/job/silicon.dm index 41d6cb974e7..5461fb1d9b9 100644 --- a/code/game/jobs/job/silicon.dm +++ b/code/game/jobs/job/silicon.dm @@ -9,7 +9,7 @@ req_admin_notify = 1 minimal_player_age = 30 exp_requirements = 300 - exp_type = "Silicon" + exp_type = EXP_TYPE_SILICON equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -29,7 +29,7 @@ selection_color = "#ddffdd" minimal_player_age = 21 exp_requirements = 300 - exp_type = "Crew" + exp_type = EXP_TYPE_CREW alt_titles = list("Android", "Robot") equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job/supervisor.dm b/code/game/jobs/job/supervisor.dm index 4ee2720162c..876706d114d 100644 --- a/code/game/jobs/job/supervisor.dm +++ b/code/game/jobs/job/supervisor.dm @@ -13,7 +13,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) minimal_access = list() //See get_access() minimal_player_age = 30 exp_requirements = 600 - exp_type = "Command" + exp_type = EXP_TYPE_COMMAND equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/heads/captain/alt(H), slot_l_ear) @@ -62,7 +62,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) req_admin_notify = 1 minimal_player_age = 21 exp_requirements = 600 - exp_type = "Supply" + exp_type = EXP_TYPE_SUPPLY access = list(access_security, access_sec_doors, access_brig, access_court, access_forensics_lockers, access_medical, access_engine, access_change_ids, access_ai_upload, access_eva, access_heads, access_all_personal_lockers, access_maint_tunnels, access_bar, access_janitor, access_construction, access_morgue, @@ -243,7 +243,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) alt_titles = list("Lawyer","Public Defender") minimal_player_age = 30 exp_requirements = 300 - exp_type = "Security" + exp_type = EXP_TYPE_SECURITY idtype = /obj/item/weapon/card/id/security equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 3a556f6d2e5..ba2e5be5d46 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -123,7 +123,7 @@ var/global/datum/controller/occupations/job_master if(job.admin_only) // No admin positions either. continue - if(!has_exp_for_job(player, job.title)) + if(job.available_in_playtime(player.client)) continue if(jobban_isbanned(player, job.title)) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index 535da5303d4..caa59a57fa5 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -1,20 +1,22 @@ +// Defines + +#define EXP_TYPE_CREW "Crew" +#define EXP_TYPE_COMMAND "Command" +#define EXP_TYPE_ENGINEERING "Engineering" +#define EXP_TYPE_SECURITY "Security" +#define EXP_TYPE_SILICON "Silicon" +#define EXP_TYPE_SERVICE "Service" +#define EXP_TYPE_MEDICAL "Medical" +#define EXP_TYPE_SCIENCE "Science" +#define EXP_TYPE_SUPPLY "Supply" +#define EXP_TYPE_SPECIAL "Special" +#define EXP_TYPE_GHOST "Ghost" +#define EXP_TYPE_EXEMPT "Exempt" + // Globals, Defines, Etc -var/global/list/exp_jobsmap = list( - "Crew" = list(), // all playtime from all jobs, together - "Command" = list(titles = command_positions), - "Engineering" = list(titles = engineering_positions), - "Security" = list(titles = security_positions), - "Silicon" = list(titles = nonhuman_positions), - "Service" = list(titles = service_positions), - "Medical" = list(titles = medical_positions), - "Science" = list(titles = science_positions), - "Supply" = list(titles = supply_positions), - "Special" = list(), // special_role - "Ghost" = list(), // dead/observer - "Exempt" = list() // special grandfather setting -) + // Admin Verbs @@ -25,53 +27,51 @@ var/global/list/exp_jobsmap = list( set name = "Check Player Playtime" if(!check_rights(R_ADMIN)) return - var/msg = "Playtime Report
    Playtime:
    " + var/msg = "Playtime ReportPlaytime:
      " for(var/client/C in clients) var/list/play_records = params2list(C.prefs.exp) - var/gen_exp_time = text2num(play_records["Crew"]) + var/gen_exp_time = text2num(play_records[EXP_TYPE_CREW]) gen_exp_time = num2text(round(gen_exp_time / 60)) + "h" - msg += "
      - [key_name_admin(C.mob)]: " + C.get_exp_general() + " " - if(msg != "") - src << browse(msg, "window=Player_playtime_check") - log_admin("[key_name(usr)] checked player playtime") - feedback_add_details("admin_verb","MCPP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + msg += "
    • - [key_name_admin(C.mob)]: " + C.get_exp_general() + "
    • " + msg += "
    " + src << browse(msg, "window=Player_playtime_check") /client/proc/cmd_show_exp_panel(var/client/C in clients) if(!check_rights(R_ADMIN)) return - var/body = "Playtime for [C.key]
    Playtime:" + var/body = "Playtime for [C.key]
    Playtime:" body += C.get_exp_report() - body += "" + body += "" src << browse(body, "window=playerplaytime;size=550x615") // Procs -/proc/has_exp_for_job(mob/M, rank) - var/datum/job/job = job_master.GetJob(rank) - if(!job) - return 1 - if(!job.exp_requirements || !job.exp_type) - return 1 - if(!job_is_xp_locked(rank)) - return 1 - if(!M.client) + +/datum/job/proc/available_in_playtime(client/C) + if(!C) return 0 - if(check_rights(R_ADMIN, 0, M)) + if(!exp_requirements || !exp_type) + return 0 + if(!job_is_xp_locked(src.title)) + return 0 + if(check_rights(R_ADMIN, 0, C.mob)) return 1 - var/list/play_records = params2list(M.client.prefs.exp) - var/isexempt = text2num(play_records["Exempt"]) + var/list/play_records = params2list(C.prefs.exp) + var/isexempt = text2num(play_records[EXP_TYPE_EXEMPT]) if(isexempt) - return 1 - var/my_exp = text2num(play_records[job.exp_type]) - var/job_requirement = text2num(job.exp_requirements) - if(config.use_exp_restrictions_heads_hours && ((rank in command_positions) || rank == "AI")) - job_requirement = text2num(config.use_exp_restrictions_heads_hours) * 60 - if(my_exp >= job_requirement) - return 1 - else return 0 + var/my_exp = text2num(play_records[exp_type]) + var/job_requirement = text2num(exp_requirements) + if(config.use_exp_restrictions_heads_hours && ((title in command_positions) || title == "AI")) + job_requirement = config.use_exp_restrictions_heads_hours * 60 + if(my_exp >= job_requirement) + return 0 + else + return (job_requirement - my_exp) + + /proc/job_is_xp_locked(jobtitle) if(!config.use_exp_restrictions_heads && ((jobtitle in command_positions) || jobtitle == "AI")) @@ -93,9 +93,9 @@ var/global/list/exp_jobsmap = list( var/list/play_records = params2list(prefs.exp) if(!play_records.len) - return "[src] has no records." + return "[key] has no records." - var/return_text = "" + var/return_text = "
      " var/list/exp_data = list() for(var/cat in exp_jobsmap) @@ -106,43 +106,47 @@ var/global/list/exp_jobsmap = list( for(var/dep in exp_data) if(exp_data[dep] > 0) - if(dep == "Exempt") - return_text += "
      - Exempt (all jobs auto-unlocked)" - else - return_text += "
      - [dep] " + get_exp_format(exp_data[dep]) + " (" + num2text(round(exp_data[dep]/exp_data["Crew"]*100)) + "%)" - + if(dep == EXP_TYPE_EXEMPT) + return_text += "
    • Exempt (all jobs auto-unlocked)
    • " + else if(exp_data[EXP_TYPE_CREW] > 0) + return_text += "
    • [dep] [get_exp_format(exp_data[dep])] (" + num2text(round(exp_data[dep]/exp_data[EXP_TYPE_CREW]*100)) + "%)
    • " + return_text += "
    " var/list/jobs_locked = list() var/list/jobs_unlocked = list() for(var/datum/job/job in job_master.occupations) if(job.exp_requirements && job.exp_type) if(!job_is_xp_locked(job.title)) continue - else if(has_exp_for_job(mob, job.title)) - jobs_unlocked += "
    - " + job.title + else if(!job.available_in_playtime(mob.client)) + jobs_unlocked += job.title else var/xp_req = job.exp_requirements if(config.use_exp_restrictions_heads_hours && ((job.title in command_positions) || job.title == "AI")) - xp_req = text2num(config.use_exp_restrictions_heads_hours) * 60 - jobs_locked += "
    - " + job.title + " (" + get_exp_format(text2num(play_records[job.exp_type])) + " / " + get_exp_format(xp_req) + " [job.exp_type] EXP)" + xp_req = config.use_exp_restrictions_heads_hours * 60 + jobs_locked += job.title + " (" + get_exp_format(text2num(play_records[job.exp_type])) + " / " + get_exp_format(xp_req) + " [job.exp_type] EXP)" if(jobs_unlocked.len) - return_text += "

    Jobs Unlocked: " + return_text += "

    Jobs Unlocked:
      " for(var/text in jobs_unlocked) - return_text += text + return_text += "
    • [text]
    • " + return_text += "
    " if(jobs_locked.len) - return_text += "

    Jobs Not Unlocked: " + return_text += "

    Jobs Not Unlocked:
      " for(var/text in jobs_locked) - return_text += text + return_text += "
    • [text]
    • " + return_text += "
    " return return_text /client/proc/get_exp_general() var/list/play_records = params2list(prefs.exp) - var/exp_gen = text2num(play_records["Crew"]) + var/exp_gen = text2num(play_records[EXP_TYPE_CREW]) return get_exp_format(exp_gen) -/client/proc/get_exp_format(var/expnum) - if(expnum > 0) +/proc/get_exp_format(var/expnum) + if(expnum > 60) return num2text(round(expnum / 60)) + "h" + else if(expnum > 0) + return num2text(expnum) + "m" else return "0h" @@ -151,47 +155,53 @@ var/global/list/exp_jobsmap = list( return -1 spawn(0) for(var/client/C in clients) - if(C.inactivity < (10 MINUTES)) + if(C.inactivity >= (10 MINUTES)) + continue - var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") - exp_read.Execute() - var/list/read_records = list() - while(exp_read.NextRow()) - read_records = params2list(exp_read.item[1]) + var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") + exp_read.Execute() + var/list/read_records = list() + while(exp_read.NextRow()) + read_records = params2list(exp_read.item[1]) - var/list/play_records = list() - for(var/rtype in exp_jobsmap) - if(text2num(read_records[rtype])) - play_records[rtype] = text2num(read_records[rtype]) - else - play_records[rtype] = 0 - - if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) - play_records["Crew"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] General EXP!") - - for(var/cat in exp_jobsmap) - if(exp_jobsmap[cat]["titles"]) - if(C.mob.mind.assigned_role in exp_jobsmap[cat]["titles"]) - play_records[cat] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] [cat] EXP!") - - if(C.mob.mind.special_role) - play_records["Special"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Special EXP!") - - else if(isobserver(C.mob)) - play_records["Ghost"] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Ghost EXP!") + var/list/play_records = list() + for(var/rtype in exp_jobsmap) + if(text2num(read_records[rtype])) + play_records[rtype] = text2num(read_records[rtype]) else - return - var/new_exp = list2params(play_records) - C.prefs.exp = new_exp - new_exp = sanitizeSQL(new_exp) - var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") - update_query.Execute() - sleep(10) \ No newline at end of file + play_records[rtype] = 0 + if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) + play_records[EXP_TYPE_CREW] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] General EXP!") + for(var/cat in exp_jobsmap) + if(exp_jobsmap[cat]["titles"]) + if(C.mob.mind.assigned_role in exp_jobsmap[cat]["titles"]) + play_records[cat] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] [cat] EXP!") + if(C.mob.mind.special_role) + play_records[EXP_TYPE_SPECIAL] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Special EXP!") + else if(isobserver(C.mob)) + play_records[EXP_TYPE_GHOST] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Ghost EXP!") + else + return + var/new_exp = list2params(play_records) + C.prefs.exp = new_exp + new_exp = sanitizeSQL(new_exp) + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") + update_query.Execute() + sleep(10) + + +/hook/roundstart/proc/exptimer() + if(!config.sql_enabled || !config.use_exp_tracking) + return 0 + spawn(0) + while(TRUE) + sleep(5 MINUTES) + update_exp(5,0) diff --git a/code/game/jobs/jobs.dm b/code/game/jobs/jobs.dm index 6af69ebed9d..0c8f6a5d47d 100644 --- a/code/game/jobs/jobs.dm +++ b/code/game/jobs/jobs.dm @@ -183,3 +183,17 @@ var/list/whitelisted_positions = list( return titles +var/global/list/exp_jobsmap = list( + EXP_TYPE_CREW = list(), // all playtime from all jobs, together + EXP_TYPE_COMMAND = list(titles = command_positions), + EXP_TYPE_ENGINEERING = list(titles = engineering_positions), + EXP_TYPE_SECURITY = list(titles = security_positions), + EXP_TYPE_SILICON = list(titles = nonhuman_positions), + EXP_TYPE_SERVICE = list(titles = service_positions), + EXP_TYPE_MEDICAL = list(titles = medical_positions), + EXP_TYPE_SCIENCE = list(titles = science_positions), + EXP_TYPE_SUPPLY = list(titles = supply_positions), + EXP_TYPE_SPECIAL = list(), // special_role + EXP_TYPE_GHOST = list(), // dead/observer + EXP_TYPE_EXEMPT = list() // special grandfather setting +) \ No newline at end of file diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index a32da447050..4d965ab38f8 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2018,8 +2018,9 @@ else if(href_list["getplaytimewindow"]) if(!check_rights(R_ADMIN)) return - var/mob/M = locate(href_list["getplaytimewindow"]) + if(!M) + return usr.client.cmd_show_exp_panel(M.client) else if(href_list["jumpto"]) diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index 50fd26b929c..8832e3fc3e4 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -552,8 +552,9 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(jobban_isbanned(user, rank)) HTML += "[rank] \[BANNED]" continue - if(!has_exp_for_job(user, job.title)) - HTML += "[rank] \[TIME]" + var/available_in_playtime = job.available_in_playtime(user.client) + if(available_in_playtime) + HTML += "[rank] \[ " + get_exp_format(available_in_playtime) + " as [job.exp_type] ]" continue if(!job.player_old_enough(user.client)) var/available_in_days = job.available_in_days(user.client) diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 6665bb54982..97e07a71fb0 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -246,7 +246,7 @@ if(!is_job_whitelisted(src, rank)) return 0 if(!job.player_old_enough(src.client)) return 0 if(job.admin_only && !(check_rights(R_EVENT, 0))) return 0 - if(!has_exp_for_job(src, rank)) + if(job.available_in_playtime(src.client)) return 0 if(config.assistantlimit) From 12209a360bd983c5f00533b6277b5bf39d51fe00 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sat, 6 Aug 2016 01:46:02 -0700 Subject: [PATCH 011/136] Update 6 --- code/game/jobs/job/security.dm | 2 +- code/game/jobs/job_exp.dm | 24 +++++++++++++---------- code/modules/admin/topic.dm | 2 +- code/modules/mob/new_player/new_player.dm | 4 ++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/code/game/jobs/job/security.dm b/code/game/jobs/job/security.dm index 22661bcb35b..aed67eaa442 100644 --- a/code/game/jobs/job/security.dm +++ b/code/game/jobs/job/security.dm @@ -63,7 +63,7 @@ minimal_access = list(access_security, access_sec_doors, access_brig, access_armory, access_court, access_maint_tunnels, access_weapons) minimal_player_age = 21 exp_requirements = 300 - exp_type = "Security" + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index caa59a57fa5..7d312b43319 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -29,21 +29,20 @@ return var/msg = "Playtime ReportPlaytime:
      " for(var/client/C in clients) - var/list/play_records = params2list(C.prefs.exp) - var/gen_exp_time = text2num(play_records[EXP_TYPE_CREW]) - gen_exp_time = num2text(round(gen_exp_time / 60)) + "h" - msg += "
    • - [key_name_admin(C.mob)]: " + C.get_exp_general() + "
    • " + msg += "
    • - [key_name_admin(C)]: " + C.get_exp_general() + "
    • " msg += "
    " src << browse(msg, "window=Player_playtime_check") -/client/proc/cmd_show_exp_panel(var/client/C in clients) +/datum/admins/proc/cmd_show_exp_panel(var/client/C) + if (!C) + return if(!check_rights(R_ADMIN)) return var/body = "Playtime for [C.key]
    Playtime:" body += C.get_exp_report() body += "" - src << browse(body, "window=playerplaytime;size=550x615") + usr << browse(body, "window=playerplaytime;size=550x615") // Procs @@ -57,7 +56,7 @@ if(!job_is_xp_locked(src.title)) return 0 if(check_rights(R_ADMIN, 0, C.mob)) - return 1 + return 0 var/list/play_records = params2list(C.prefs.exp) var/isexempt = text2num(play_records[EXP_TYPE_EXEMPT]) if(isexempt) @@ -109,7 +108,11 @@ if(dep == EXP_TYPE_EXEMPT) return_text += "
  • Exempt (all jobs auto-unlocked)
  • " else if(exp_data[EXP_TYPE_CREW] > 0) - return_text += "
  • [dep] [get_exp_format(exp_data[dep])] (" + num2text(round(exp_data[dep]/exp_data[EXP_TYPE_CREW]*100)) + "%)
  • " + var/my_pc = num2text(round(exp_data[dep]/exp_data[EXP_TYPE_CREW]*100)) + return_text += "
  • [dep] [get_exp_format(exp_data[dep])] ([my_pc]%)
  • " + else + return_text += "
  • [dep] [get_exp_format(exp_data[dep])]
  • " + return_text += "" var/list/jobs_locked = list() var/list/jobs_unlocked = list() @@ -123,7 +126,7 @@ var/xp_req = job.exp_requirements if(config.use_exp_restrictions_heads_hours && ((job.title in command_positions) || job.title == "AI")) xp_req = config.use_exp_restrictions_heads_hours * 60 - jobs_locked += job.title + " (" + get_exp_format(text2num(play_records[job.exp_type])) + " / " + get_exp_format(xp_req) + " [job.exp_type] EXP)" + jobs_locked += "[job.title] [get_exp_format(text2num(play_records[job.exp_type]))] / [get_exp_format(xp_req)] [job.exp_type] EXP)" if(jobs_unlocked.len) return_text += "

    Jobs Unlocked:
      " for(var/text in jobs_unlocked) @@ -200,8 +203,9 @@ /hook/roundstart/proc/exptimer() if(!config.sql_enabled || !config.use_exp_tracking) - return 0 + return 1 spawn(0) while(TRUE) sleep(5 MINUTES) update_exp(5,0) + return 1 diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 4d965ab38f8..85c826a5594 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2021,7 +2021,7 @@ var/mob/M = locate(href_list["getplaytimewindow"]) if(!M) return - usr.client.cmd_show_exp_panel(M.client) + cmd_show_exp_panel(M.client) else if(href_list["jumpto"]) if(!check_rights(R_ADMIN)) return diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 97e07a71fb0..42293556481 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -244,9 +244,9 @@ if(!job.is_position_available()) return 0 if(jobban_isbanned(src,rank)) return 0 if(!is_job_whitelisted(src, rank)) return 0 - if(!job.player_old_enough(src.client)) return 0 + if(!job.player_old_enough(client)) return 0 if(job.admin_only && !(check_rights(R_EVENT, 0))) return 0 - if(job.available_in_playtime(src.client)) + if(job.available_in_playtime(client)) return 0 if(config.assistantlimit) From e1dccb435b81b8e8ff84356ede292704d2430d5e Mon Sep 17 00:00:00 2001 From: Kyep Date: Sat, 6 Aug 2016 14:39:35 -0700 Subject: [PATCH 012/136] Update 6 - Split EXP_TYPE_CREW into EXP_TYPE_LIVING (all living mobs) and EXP_TYPE_CREW (actual crew positions). Job unlocks use EXP_TYPE_CREW. General playtime reports use EXP_TYPE_LIVING. Playing corgi doesn't help unlock jobs, but it does show in your stats. - Added tracking for karma-locked jobs as a department in stats. - Added quite a few safety checks. - Split the per-client part of update_exp into update_exp_client - Added new config option to let admins bypass the system, intended for testing - Moved defines to code\__DEFINES\preferences.dm --- code/__DEFINES/preferences.dm | 16 ++++ code/controllers/configuration.dm | 4 + code/game/jobs/job_exp.dm | 131 ++++++++++++++---------------- code/game/jobs/jobs.dm | 14 ++-- code/modules/admin/admin.dm | 2 +- code/modules/admin/topic.dm | 4 +- config/example/config.txt | 2 + 7 files changed, 93 insertions(+), 80 deletions(-) diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index 8ac165cec6a..24c8235c83a 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -27,3 +27,19 @@ #define CHAT_NO_ADMINLOGS 16384 #define TOGGLES_DEFAULT (CHAT_OOC|CHAT_DEAD|CHAT_GHOSTEARS|CHAT_GHOSTSIGHT|CHAT_PRAYER|CHAT_RADIO|CHAT_ATTACKLOGS|CHAT_LOOC|MEMBER_PUBLIC) + +// Playtime tracking system, see jobs_exp.dm +#define EXP_TYPE_LIVING "Living" +#define EXP_TYPE_CREW "Crew" +#define EXP_TYPE_COMMAND "Command" +#define EXP_TYPE_ENGINEERING "Engineering" +#define EXP_TYPE_MEDICAL "Medical" +#define EXP_TYPE_SCIENCE "Science" +#define EXP_TYPE_SUPPLY "Supply" +#define EXP_TYPE_SECURITY "Security" +#define EXP_TYPE_SILICON "Silicon" +#define EXP_TYPE_SERVICE "Service" +#define EXP_TYPE_WHITELIST "Whitelist" +#define EXP_TYPE_SPECIAL "Special" +#define EXP_TYPE_GHOST "Ghost" +#define EXP_TYPE_EXEMPT "Exempt" \ No newline at end of file diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index c3779ab095d..67939f227b5 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -131,6 +131,7 @@ var/use_exp_restrictions_heads = 0 var/use_exp_restrictions_heads_hours = 0 var/use_exp_restrictions_other = 0 + var/use_exp_restrictions_admin_bypass = 0 var/simultaneous_pm_warning_timeout = 100 @@ -256,6 +257,9 @@ if("use_exp_restrictions_other") config.use_exp_restrictions_other = 1 + if("use_exp_restrictions_admin_bypass") + config.use_exp_restrictions_admin_bypass = 1 + if("jobs_have_minimal_access") config.jobs_have_minimal_access = 1 diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index 7d312b43319..dfeb9520502 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -1,27 +1,5 @@ - -// Defines - -#define EXP_TYPE_CREW "Crew" -#define EXP_TYPE_COMMAND "Command" -#define EXP_TYPE_ENGINEERING "Engineering" -#define EXP_TYPE_SECURITY "Security" -#define EXP_TYPE_SILICON "Silicon" -#define EXP_TYPE_SERVICE "Service" -#define EXP_TYPE_MEDICAL "Medical" -#define EXP_TYPE_SCIENCE "Science" -#define EXP_TYPE_SUPPLY "Supply" -#define EXP_TYPE_SPECIAL "Special" -#define EXP_TYPE_GHOST "Ghost" -#define EXP_TYPE_EXEMPT "Exempt" - -// Globals, Defines, Etc - - - - // Admin Verbs - /client/proc/cmd_admin_check_player_exp() //Allows admins to determine who the newer players are. set category = "Admin" set name = "Check Player Playtime" @@ -29,20 +7,21 @@ return var/msg = "Playtime ReportPlaytime:
      " src << browse(msg, "window=Player_playtime_check") /datum/admins/proc/cmd_show_exp_panel(var/client/C) - if (!C) + if(!C) + to_chat(usr, "ERROR: Mob not found.") return if(!check_rights(R_ADMIN)) return var/body = "Playtime for [C.key]
      Playtime:" body += C.get_exp_report() body += "" - usr << browse(body, "window=playerplaytime;size=550x615") + usr << browse(body, "window=playerplaytime[C.ckey];size=550x615") // Procs @@ -55,7 +34,7 @@ return 0 if(!job_is_xp_locked(src.title)) return 0 - if(check_rights(R_ADMIN, 0, C.mob)) + if(config.use_exp_restrictions_admin_bypass && check_rights(R_ADMIN, 0, C.mob)) return 0 var/list/play_records = params2list(C.prefs.exp) var/isexempt = text2num(play_records[EXP_TYPE_EXEMPT]) @@ -107,12 +86,13 @@ if(exp_data[dep] > 0) if(dep == EXP_TYPE_EXEMPT) return_text += "
    • Exempt (all jobs auto-unlocked)
    • " - else if(exp_data[EXP_TYPE_CREW] > 0) - var/my_pc = num2text(round(exp_data[dep]/exp_data[EXP_TYPE_CREW]*100)) + else if(exp_data[EXP_TYPE_LIVING] > 0) + var/my_pc = num2text(round(exp_data[dep]/exp_data[EXP_TYPE_LIVING]*100)) return_text += "
    • [dep] [get_exp_format(exp_data[dep])] ([my_pc]%)
    • " else return_text += "
    • [dep] [get_exp_format(exp_data[dep])]
    • " - + if(config.use_exp_restrictions_admin_bypass && check_rights(R_ADMIN, 0, mob)) + return_text += "
    • Admin (all jobs auto-unlocked)
    • " return_text += "
    " var/list/jobs_locked = list() var/list/jobs_unlocked = list() @@ -140,9 +120,9 @@ return return_text -/client/proc/get_exp_general() +/client/proc/get_exp_living() var/list/play_records = params2list(prefs.exp) - var/exp_gen = text2num(play_records[EXP_TYPE_CREW]) + var/exp_gen = text2num(play_records[EXP_TYPE_LIVING]) return get_exp_format(exp_gen) /proc/get_exp_format(var/expnum) @@ -153,53 +133,60 @@ else return "0h" -/proc/update_exp(var/minutes, var/announce_changes = 0) +/proc/update_exp(var/mins, var/ann = 0) if(!establish_db_connection()) return -1 spawn(0) - for(var/client/C in clients) - if(C.inactivity >= (10 MINUTES)) + for(var/client/L in clients) + if(L.inactivity >= (10 MINUTES)) continue - - var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") - exp_read.Execute() - var/list/read_records = list() - while(exp_read.NextRow()) - read_records = params2list(exp_read.item[1]) - - var/list/play_records = list() - for(var/rtype in exp_jobsmap) - if(text2num(read_records[rtype])) - play_records[rtype] = text2num(read_records[rtype]) - else - play_records[rtype] = 0 - if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) - play_records[EXP_TYPE_CREW] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] General EXP!") - for(var/cat in exp_jobsmap) - if(exp_jobsmap[cat]["titles"]) - if(C.mob.mind.assigned_role in exp_jobsmap[cat]["titles"]) - play_records[cat] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] [cat] EXP!") - if(C.mob.mind.special_role) - play_records[EXP_TYPE_SPECIAL] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Special EXP!") - else if(isobserver(C.mob)) - play_records[EXP_TYPE_GHOST] += minutes - if(announce_changes) - to_chat(C.mob,"You got: [minutes] Ghost EXP!") - else - return - var/new_exp = list2params(play_records) - C.prefs.exp = new_exp - new_exp = sanitizeSQL(new_exp) - var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") - update_query.Execute() + spawn(0) + update_exp_client(L, mins, ann) sleep(10) +/proc/update_exp_client(var/client/C, var/minutes, var/announce_changes = 0) + if(!C ||!C.ckey) + return + var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") + exp_read.Execute() + var/list/read_records = list() + var/hasread = 0 + while(exp_read.NextRow()) + read_records = params2list(exp_read.item[1]) + hasread = 1 + if(!hasread) + return + var/list/play_records = list() + for(var/rtype in exp_jobsmap) + if(text2num(read_records[rtype])) + play_records[rtype] = text2num(read_records[rtype]) + else + play_records[rtype] = 0 + if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) + play_records[EXP_TYPE_LIVING] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Living EXP!") + for(var/cat in exp_jobsmap) + if(exp_jobsmap[cat]["titles"]) + if(C.mob.mind.assigned_role in exp_jobsmap[cat]["titles"]) + play_records[cat] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] [cat] EXP!") + if(C.mob.mind.special_role) + play_records[EXP_TYPE_SPECIAL] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Special EXP!") + else if(isobserver(C.mob)) + play_records[EXP_TYPE_GHOST] += minutes + if(announce_changes) + to_chat(C.mob,"You got: [minutes] Ghost EXP!") + else + return + var/new_exp = list2params(play_records) + C.prefs.exp = new_exp + new_exp = sanitizeSQL(new_exp) + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") + update_query.Execute() /hook/roundstart/proc/exptimer() if(!config.sql_enabled || !config.use_exp_tracking) diff --git a/code/game/jobs/jobs.dm b/code/game/jobs/jobs.dm index 0c8f6a5d47d..0604ec0f428 100644 --- a/code/game/jobs/jobs.dm +++ b/code/game/jobs/jobs.dm @@ -184,16 +184,18 @@ var/list/whitelisted_positions = list( return titles var/global/list/exp_jobsmap = list( - EXP_TYPE_CREW = list(), // all playtime from all jobs, together + EXP_TYPE_LIVING = list(), // all living mobs + EXP_TYPE_CREW = list(titles = command_positions + engineering_positions + medical_positions + science_positions + support_positions + supply_positions + security_positions + civilian_positions + whitelisted_positions), // crew positions EXP_TYPE_COMMAND = list(titles = command_positions), EXP_TYPE_ENGINEERING = list(titles = engineering_positions), - EXP_TYPE_SECURITY = list(titles = security_positions), - EXP_TYPE_SILICON = list(titles = nonhuman_positions), - EXP_TYPE_SERVICE = list(titles = service_positions), EXP_TYPE_MEDICAL = list(titles = medical_positions), EXP_TYPE_SCIENCE = list(titles = science_positions), EXP_TYPE_SUPPLY = list(titles = supply_positions), - EXP_TYPE_SPECIAL = list(), // special_role - EXP_TYPE_GHOST = list(), // dead/observer + EXP_TYPE_SECURITY = list(titles = security_positions), + EXP_TYPE_SILICON = list(titles = nonhuman_positions), + EXP_TYPE_SERVICE = list(titles = service_positions), + EXP_TYPE_WHITELIST = list(titles = whitelisted_positions), // karma-locked jobs + EXP_TYPE_SPECIAL = list(), // antags, ERT, etc + EXP_TYPE_GHOST = list(), // dead people, observers EXP_TYPE_EXEMPT = list() // special grandfather setting ) \ No newline at end of file diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index f0faa025854..be3fe24259c 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -43,7 +43,7 @@ var/global/nologevent = 0 if(M.client) body += " played by [M.client] " body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\] " - body += "\[" + M.client.get_exp_general() + "\]" + body += "\[" + M.client.get_exp_living() + "\]" if(istype(M, /mob/new_player)) body += " Hasn't Entered Game " diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 85c826a5594..71a2c81011e 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2017,9 +2017,11 @@ fax_panel(usr) else if(href_list["getplaytimewindow"]) - if(!check_rights(R_ADMIN)) return + if(!check_rights(R_ADMIN)) + return var/mob/M = locate(href_list["getplaytimewindow"]) if(!M) + to_chat(usr, "ERROR: Mob not found.") return cmd_show_exp_panel(M.client) diff --git a/config/example/config.txt b/config/example/config.txt index 350c59b079d..9a0fe069c77 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -20,10 +20,12 @@ JOBS_HAVE_MINIMAL_ACCESS ## USE_EXP_TRACKING enables playtime/exp tracking. REQUIRES DATABASE TO BE ENABLED. ## USE_EXP_RESTRICTIONS_HEADS enables playtime/exp requirements for head jobs. If USE_EXP_RESTRICTIONS_HEADS_HOURS is enabled also, it uses that value for their time requirements. If not, it goes by the values defined on their job definitions in code. ## USE_EXP_RESTRICTIONS_OTHER enables playtime/exp requirements for some dangerous non-head jobs, like engineer, scientist, security officer, etc. The requirements for these jobs are always taken from code. +## USE_EXP_RESTRICTIONS_ADMIN_BYPASS lets admins always bypass the restrictions. Useful to turn off for testing. #USE_EXP_TRACKING #USE_EXP_RESTRICTIONS_HEADS #USE_EXP_RESTRICTIONS_HEADS_HOURS 15 #USE_EXP_RESTRICTIONS_OTHER +#USE_EXP_RESTRICTIONS_ADMIN_BYPASS ## Unhash this entry to have certain antagonist roles require your account to be at least a certain number of days old to select. You can configure the exact age requirement for different antag roles by editing special_role_times in /code/modules/client/preferences.dm. ## See USE_AGE_RESTRICTION_FOR_JOBS for more information From d7163f4ec171b2698c033bc88320596683638fb6 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 7 Aug 2016 20:33:46 -0700 Subject: [PATCH 013/136] More Krausus Stuff - Changed EXP_TYPE_CREW to include nonhuman positions, and use | rather than +. - Changed update_exp_client into a client proc... for some reason - Added logging/returning if SQL read query fails in update_exp_client --- code/game/jobs/job_exp.dm | 40 +++++++++++++++++++++++---------------- code/game/jobs/jobs.dm | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index dfeb9520502..1658fd3759b 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -141,14 +141,18 @@ if(L.inactivity >= (10 MINUTES)) continue spawn(0) - update_exp_client(L, mins, ann) + L.update_exp_client(mins, ann) sleep(10) -/proc/update_exp_client(var/client/C, var/minutes, var/announce_changes = 0) - if(!C ||!C.ckey) +/client/proc/update_exp_client(var/minutes, var/announce_changes = 0) + if(!src ||!ckey) + return + var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[ckey]'") + if(!exp_read.Execute()) + var/err = exp_read.ErrorMsg() + log_game("SQL ERROR during exp_update_client read. Error : \[[err]\]\n") + message_admins("SQL ERROR during exp_update_client read. Error : \[[err]\]\n") return - var/DBQuery/exp_read = dbcon.NewQuery("SELECT exp FROM [format_table_name("player")] WHERE ckey='[C.ckey]'") - exp_read.Execute() var/list/read_records = list() var/hasread = 0 while(exp_read.NextRow()) @@ -162,31 +166,35 @@ play_records[rtype] = text2num(read_records[rtype]) else play_records[rtype] = 0 - if(C.mob.stat == CONSCIOUS && C.mob.mind.assigned_role) + if(mob.stat == CONSCIOUS && mob.mind.assigned_role) play_records[EXP_TYPE_LIVING] += minutes if(announce_changes) - to_chat(C.mob,"You got: [minutes] Living EXP!") + to_chat(mob,"You got: [minutes] Living EXP!") for(var/cat in exp_jobsmap) if(exp_jobsmap[cat]["titles"]) - if(C.mob.mind.assigned_role in exp_jobsmap[cat]["titles"]) + if(mob.mind.assigned_role in exp_jobsmap[cat]["titles"]) play_records[cat] += minutes if(announce_changes) - to_chat(C.mob,"You got: [minutes] [cat] EXP!") - if(C.mob.mind.special_role) + to_chat(mob,"You got: [minutes] [cat] EXP!") + if(mob.mind.special_role) play_records[EXP_TYPE_SPECIAL] += minutes if(announce_changes) - to_chat(C.mob,"You got: [minutes] Special EXP!") - else if(isobserver(C.mob)) + to_chat(mob,"You got: [minutes] Special EXP!") + else if(isobserver(mob)) play_records[EXP_TYPE_GHOST] += minutes if(announce_changes) - to_chat(C.mob,"You got: [minutes] Ghost EXP!") + to_chat(mob,"You got: [minutes] Ghost EXP!") else return var/new_exp = list2params(play_records) - C.prefs.exp = new_exp + prefs.exp = new_exp new_exp = sanitizeSQL(new_exp) - var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[C.ckey]'") - update_query.Execute() + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[ckey]'") + if(!update_query.Execute()) + var/err = update_query.ErrorMsg() + log_game("SQL ERROR during exp_update_client write. Error : \[[err]\]\n") + message_admins("SQL ERROR during exp_update_client write. Error : \[[err]\]\n") + return /hook/roundstart/proc/exptimer() if(!config.sql_enabled || !config.use_exp_tracking) diff --git a/code/game/jobs/jobs.dm b/code/game/jobs/jobs.dm index 0604ec0f428..a1b3b83841d 100644 --- a/code/game/jobs/jobs.dm +++ b/code/game/jobs/jobs.dm @@ -185,7 +185,7 @@ var/list/whitelisted_positions = list( var/global/list/exp_jobsmap = list( EXP_TYPE_LIVING = list(), // all living mobs - EXP_TYPE_CREW = list(titles = command_positions + engineering_positions + medical_positions + science_positions + support_positions + supply_positions + security_positions + civilian_positions + whitelisted_positions), // crew positions + EXP_TYPE_CREW = list(titles = command_positions | engineering_positions | medical_positions | science_positions | support_positions | supply_positions | security_positions | civilian_positions | nonhuman_positions | whitelisted_positions), // crew positions EXP_TYPE_COMMAND = list(titles = command_positions), EXP_TYPE_ENGINEERING = list(titles = engineering_positions), EXP_TYPE_MEDICAL = list(titles = medical_positions), From a5c953bfdc46b3157619e3ed0a60ee7a50c3a294 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 7 Aug 2016 22:24:16 -0700 Subject: [PATCH 014/136] Counts only AIs/Borgs for silicons dept --- code/game/jobs/jobs.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/jobs/jobs.dm b/code/game/jobs/jobs.dm index a1b3b83841d..c6730174e1e 100644 --- a/code/game/jobs/jobs.dm +++ b/code/game/jobs/jobs.dm @@ -185,14 +185,14 @@ var/list/whitelisted_positions = list( var/global/list/exp_jobsmap = list( EXP_TYPE_LIVING = list(), // all living mobs - EXP_TYPE_CREW = list(titles = command_positions | engineering_positions | medical_positions | science_positions | support_positions | supply_positions | security_positions | civilian_positions | nonhuman_positions | whitelisted_positions), // crew positions + EXP_TYPE_CREW = list(titles = command_positions | engineering_positions | medical_positions | science_positions | support_positions | supply_positions | security_positions | civilian_positions | list("AI","Cyborg") | whitelisted_positions), // crew positions EXP_TYPE_COMMAND = list(titles = command_positions), EXP_TYPE_ENGINEERING = list(titles = engineering_positions), EXP_TYPE_MEDICAL = list(titles = medical_positions), EXP_TYPE_SCIENCE = list(titles = science_positions), EXP_TYPE_SUPPLY = list(titles = supply_positions), EXP_TYPE_SECURITY = list(titles = security_positions), - EXP_TYPE_SILICON = list(titles = nonhuman_positions), + EXP_TYPE_SILICON = list(titles = list("AI","Cyborg")), EXP_TYPE_SERVICE = list(titles = service_positions), EXP_TYPE_WHITELIST = list(titles = whitelisted_positions), // karma-locked jobs EXP_TYPE_SPECIAL = list(), // antags, ERT, etc From e64215ddb1587576afc85718b53b7e0262e6f124 Mon Sep 17 00:00:00 2001 From: Kyep Date: Mon, 8 Aug 2016 23:04:26 -0700 Subject: [PATCH 015/136] Update 7 - Fix: Drones now get assigned_role = Drone. - Tweak: AI is no longer considered a head job for playtime system configuration purposes. - Tweak: Job gating (when enabled - its off by default) is based on Crew playtime now. This is for all jobs, including heads and AI. Gating based on department playtime is still possible, but based on a separate config option that's also turned off by default. --- code/controllers/configuration.dm | 4 +++ code/game/jobs/job/engineering.dm | 3 ++- code/game/jobs/job/job.dm | 1 + code/game/jobs/job/medical.dm | 3 ++- code/game/jobs/job/science.dm | 3 ++- code/game/jobs/job/security.dm | 3 ++- code/game/jobs/job/silicon.dm | 4 +-- code/game/jobs/job/supervisor.dm | 11 +++++--- code/game/jobs/job_exp.dm | 26 ++++++++++++------- code/modules/client/preference/preferences.dm | 2 +- .../mob/living/silicon/robot/drone/drone.dm | 1 + config/example/config.txt | 11 +++++--- 12 files changed, 47 insertions(+), 25 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 67939f227b5..f1734d664f6 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -130,6 +130,7 @@ var/use_exp_tracking = 0 var/use_exp_restrictions_heads = 0 var/use_exp_restrictions_heads_hours = 0 + var/use_exp_restrictions_heads_department = 0 var/use_exp_restrictions_other = 0 var/use_exp_restrictions_admin_bypass = 0 @@ -254,6 +255,9 @@ if("use_exp_restrictions_heads_hours") config.use_exp_restrictions_heads_hours = text2num(value) + if("use_exp_restrictions_heads_department") + config.use_exp_restrictions_heads_department = 1 + if("use_exp_restrictions_other") config.use_exp_restrictions_other = 1 diff --git a/code/game/jobs/job/engineering.dm b/code/game/jobs/job/engineering.dm index dd88a6496ab..9c182ad86c3 100644 --- a/code/game/jobs/job/engineering.dm +++ b/code/game/jobs/job/engineering.dm @@ -18,7 +18,8 @@ access_ce, access_RC_announce, access_keycard_auth, access_tcomsat, access_minisat, access_mechanic, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = EXP_TYPE_ENGINEERING + exp_type = EXP_TYPE_CREW + exp_type_department = EXP_TYPE_ENGINEERING equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/job.dm b/code/game/jobs/job/job.dm index 209127d9abe..8b372b13f9d 100644 --- a/code/game/jobs/job/job.dm +++ b/code/game/jobs/job/job.dm @@ -43,6 +43,7 @@ var/exp_requirements = 0 var/exp_type = "" + var/exp_type_department = "" var/admin_only = 0 var/spawn_ert = 0 diff --git a/code/game/jobs/job/medical.dm b/code/game/jobs/job/medical.dm index d623a79a3d1..f4b382db34b 100644 --- a/code/game/jobs/job/medical.dm +++ b/code/game/jobs/job/medical.dm @@ -16,7 +16,8 @@ access_keycard_auth, access_sec_doors, access_psychiatrist, access_maint_tunnels, access_paramedic, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = EXP_TYPE_MEDICAL + exp_type = EXP_TYPE_CREW + exp_type_department = EXP_TYPE_MEDICAL equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/science.dm b/code/game/jobs/job/science.dm index 090b6a2adef..8c3f26304db 100644 --- a/code/game/jobs/job/science.dm +++ b/code/game/jobs/job/science.dm @@ -18,7 +18,8 @@ access_RC_announce, access_keycard_auth, access_tcomsat, access_gateway, access_xenoarch, access_minisat, access_maint_tunnels, access_mineral_storeroom) minimal_player_age = 21 exp_requirements = 600 - exp_type = EXP_TYPE_SCIENCE + exp_type = EXP_TYPE_CREW + exp_type_department = EXP_TYPE_SCIENCE // All science-y guys get bonuses for maxing out their tech. required_objectives=list( diff --git a/code/game/jobs/job/security.dm b/code/game/jobs/job/security.dm index aed67eaa442..dd52f651cba 100644 --- a/code/game/jobs/job/security.dm +++ b/code/game/jobs/job/security.dm @@ -18,7 +18,8 @@ access_heads, access_hos, access_RC_announce, access_keycard_auth, access_gateway, access_pilot, access_weapons) minimal_player_age = 21 exp_requirements = 600 - exp_type = EXP_TYPE_SECURITY + exp_type = EXP_TYPE_CREW + exp_type_department = EXP_TYPE_SECURITY equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/silicon.dm b/code/game/jobs/job/silicon.dm index 5461fb1d9b9..eedb50a8412 100644 --- a/code/game/jobs/job/silicon.dm +++ b/code/game/jobs/job/silicon.dm @@ -8,8 +8,8 @@ supervisors = "your laws" req_admin_notify = 1 minimal_player_age = 30 - exp_requirements = 300 - exp_type = EXP_TYPE_SILICON + exp_requirements = 600 + exp_type = EXP_TYPE_CREW equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/supervisor.dm b/code/game/jobs/job/supervisor.dm index 876706d114d..ee176d1a607 100644 --- a/code/game/jobs/job/supervisor.dm +++ b/code/game/jobs/job/supervisor.dm @@ -13,7 +13,8 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) minimal_access = list() //See get_access() minimal_player_age = 30 exp_requirements = 600 - exp_type = EXP_TYPE_COMMAND + exp_type = EXP_TYPE_CREW + exp_type_department = EXP_TYPE_COMMAND equip(var/mob/living/carbon/human/H) if(!H) return 0 H.equip_or_collect(new /obj/item/device/radio/headset/heads/captain/alt(H), slot_l_ear) @@ -62,7 +63,8 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) req_admin_notify = 1 minimal_player_age = 21 exp_requirements = 600 - exp_type = EXP_TYPE_SUPPLY + exp_type = EXP_TYPE_CREW + exp_type_department = EXP_TYPE_SUPPLY access = list(access_security, access_sec_doors, access_brig, access_court, access_forensics_lockers, access_medical, access_engine, access_change_ids, access_ai_upload, access_eva, access_heads, access_all_personal_lockers, access_maint_tunnels, access_bar, access_janitor, access_construction, access_morgue, @@ -242,8 +244,9 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) minimal_access = list(access_lawyer, access_court, access_sec_doors, access_maint_tunnels) alt_titles = list("Lawyer","Public Defender") minimal_player_age = 30 - exp_requirements = 300 - exp_type = EXP_TYPE_SECURITY + exp_requirements = 600 + exp_type = EXP_TYPE_CREW + exp_type_department = EXP_TYPE_SECURITY idtype = /obj/item/weapon/card/id/security equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index 1658fd3759b..028cc37f8ae 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -40,21 +40,29 @@ var/isexempt = text2num(play_records[EXP_TYPE_EXEMPT]) if(isexempt) return 0 - var/my_exp = text2num(play_records[exp_type]) - var/job_requirement = text2num(exp_requirements) - if(config.use_exp_restrictions_heads_hours && ((title in command_positions) || title == "AI")) - job_requirement = config.use_exp_restrictions_heads_hours * 60 + var/my_exp = text2num(play_records[get_exp_req_type()]) + var/job_requirement = text2num(get_exp_req_amount()) if(my_exp >= job_requirement) return 0 else return (job_requirement - my_exp) +/datum/job/proc/get_exp_req_amount() + if(title in command_positions) + if(config.use_exp_restrictions_heads_hours) + return config.use_exp_restrictions_heads_hours * 60 + return exp_requirements +/datum/job/proc/get_exp_req_type() + if(title in command_positions) + if(config.use_exp_restrictions_heads_department && exp_type_department) + return exp_type_department + return exp_type /proc/job_is_xp_locked(jobtitle) - if(!config.use_exp_restrictions_heads && ((jobtitle in command_positions) || jobtitle == "AI")) + if(!config.use_exp_restrictions_heads && jobtitle in command_positions) return 0 - if(!config.use_exp_restrictions_other && !((jobtitle in command_positions) || jobtitle == "AI")) + if(!config.use_exp_restrictions_other && !(jobtitle in command_positions)) return 0 return 1 @@ -103,10 +111,8 @@ else if(!job.available_in_playtime(mob.client)) jobs_unlocked += job.title else - var/xp_req = job.exp_requirements - if(config.use_exp_restrictions_heads_hours && ((job.title in command_positions) || job.title == "AI")) - xp_req = config.use_exp_restrictions_heads_hours * 60 - jobs_locked += "[job.title] [get_exp_format(text2num(play_records[job.exp_type]))] / [get_exp_format(xp_req)] [job.exp_type] EXP)" + var/xp_req = job.get_exp_req_amount() + jobs_locked += "[job.title] [get_exp_format(text2num(play_records[job.get_exp_req_type()]))] / [get_exp_format(xp_req)] as [job.get_exp_req_type()])" if(jobs_unlocked.len) return_text += "

    Jobs Unlocked: