diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 1fbf4b5e8d..350a1ea839 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -94,6 +94,7 @@ var/admin_legacy_system = 0 //Defines whether the server uses the legacy admin system with admins.txt or the SQL system. Config option in config.txt var/ban_legacy_system = 0 //Defines whether the server uses the legacy banning system with the files in /data or the SQL system. Config option in config.txt + var/use_age_restriction_for_jobs = 0 //Do jobs use account age restrictions? --requires database var/assistant_maint = 0 //Do assistants get maint access? var/gateway_delay = 18000 //How long the gateway takes before it activates. Default is half an hour. @@ -151,6 +152,9 @@ if ("ban_legacy_system") config.ban_legacy_system = 1 + if ("use_age_restriction_for_jobs") + config.use_age_restriction_for_jobs = 1 + if ("jobs_have_minimal_access") config.jobs_have_minimal_access = 1 diff --git a/code/game/jobs/job/captain.dm b/code/game/jobs/job/captain.dm index a514f31f9d..436d1485e7 100644 --- a/code/game/jobs/job/captain.dm +++ b/code/game/jobs/job/captain.dm @@ -11,6 +11,7 @@ req_admin_notify = 1 access = list() //See get_access() minimal_access = list() //See get_access() + minimal_player_age = 14 equip(var/mob/living/carbon/human/H) @@ -53,6 +54,7 @@ selection_color = "#ddddff" idtype = /obj/item/weapon/card/id/silver req_admin_notify = 1 + minimal_player_age = 10 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/engineering.dm b/code/game/jobs/job/engineering.dm index 50fbf626da..cc4750fa41 100644 --- a/code/game/jobs/job/engineering.dm +++ b/code/game/jobs/job/engineering.dm @@ -17,6 +17,7 @@ access_teleporter, access_external_airlocks, access_atmospherics, access_emergency_storage, access_eva, access_heads, access_construction, access_sec_doors, access_ce, access_RC_announce, access_keycard_auth, access_tcomsat) + minimal_player_age = 7 equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job/job.dm b/code/game/jobs/job/job.dm index 7914690d50..78b3d755c3 100644 --- a/code/game/jobs/job/job.dm +++ b/code/game/jobs/job/job.dm @@ -35,6 +35,9 @@ //If this is set to 1, a text is printed to the player when jobs are assigned, telling him that he should let admins know that he has to disconnect. var/req_admin_notify + //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 + /datum/job/proc/equip(var/mob/living/carbon/human/H) return 1 @@ -45,4 +48,23 @@ if(config.jobs_have_minimal_access) return src.minimal_access else - return src.access \ No newline at end of file + return src.access + +//If the configuration option is set to require players to be logged as old enough to play certain jobs, then this proc checks that they are, otherwise it just returns 1 +/datum/job/proc/player_old_enough(client/C) + if(available_in_days(C) == 0) + return 1 //Available in 0 days = available right now = player is old enough to play. + return 0 + + +/datum/job/proc/available_in_days(client/C) + if(!C) + return 0 + if(!config.use_age_restriction_for_jobs) + return 0 + if(!isnum(C.player_age)) + return 0 //This is only a number if the db connection is established, otherwise it is text: "Requires database", meaning these restrictions cannot be enforced + if(!isnum(minimal_player_age)) + return 0 + + return max(0, minimal_player_age - C.player_age) diff --git a/code/game/jobs/job/medical.dm b/code/game/jobs/job/medical.dm index 73a7ea1198..c360852c2c 100644 --- a/code/game/jobs/job/medical.dm +++ b/code/game/jobs/job/medical.dm @@ -15,7 +15,7 @@ minimal_access = list(access_medical, access_morgue, access_genetics, access_heads, access_chemistry, access_virology, access_cmo, access_surgery, access_RC_announce, access_keycard_auth, access_sec_doors) - + minimal_player_age = 7 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 19ddab7834..faf4c36648 100644 --- a/code/game/jobs/job/science.dm +++ b/code/game/jobs/job/science.dm @@ -17,7 +17,7 @@ access_tox_storage, access_teleporter, access_sec_doors, access_research, access_robotics, access_xenobiology, access_ai_upload, access_RC_announce, access_keycard_auth, access_tcomsat, access_gateway) - + minimal_player_age = 7 equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job/security.dm b/code/game/jobs/job/security.dm index 1e2b90ef99..b722b0ccb5 100644 --- a/code/game/jobs/job/security.dm +++ b/code/game/jobs/job/security.dm @@ -17,7 +17,7 @@ access_forensics_lockers, access_morgue, access_maint_tunnels, access_all_personal_lockers, access_research, access_engine, access_mining, access_medical, access_construction, access_mailsorting, access_heads, access_hos, access_RC_announce, access_keycard_auth, access_gateway) - + minimal_player_age = 14 equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -57,7 +57,7 @@ selection_color = "#ffeeee" access = list(access_security, access_sec_doors, access_brig, access_armory, access_court) minimal_access = list(access_security, access_sec_doors, access_brig, access_armory, access_court) - + minimal_player_age = 7 equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -97,6 +97,7 @@ selection_color = "#ffeeee" access = list(access_sec_doors, access_forensics_lockers, access_morgue, access_maint_tunnels, access_court) minimal_access = list(access_sec_doors, access_forensics_lockers, access_morgue, access_maint_tunnels, access_court) + minimal_player_age = 7 equip(var/mob/living/carbon/human/H) @@ -142,6 +143,7 @@ selection_color = "#ffeeee" access = list(access_security, access_sec_doors, access_brig, access_court) minimal_access = list(access_security, access_sec_doors, access_brig, access_court) + minimal_player_age = 7 equip(var/mob/living/carbon/human/H) diff --git a/code/game/jobs/job/silicon.dm b/code/game/jobs/job/silicon.dm index aac5809141..853f198953 100644 --- a/code/game/jobs/job/silicon.dm +++ b/code/game/jobs/job/silicon.dm @@ -8,7 +8,7 @@ selection_color = "#ccffcc" supervisors = "your laws" req_admin_notify = 1 - + minimal_player_age = 30 equip(var/mob/living/carbon/human/H) if(!H) return 0 @@ -25,6 +25,7 @@ spawn_positions = 1 supervisors = "your laws and the AI" //Nodrak selection_color = "#ddffdd" + minimal_player_age = 21 equip(var/mob/living/carbon/human/H) if(!H) return 0 diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 465ef7f649..40110fd354 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -45,6 +45,7 @@ var/global/datum/controller/occupations/job_master var/datum/job/job = GetJob(rank) if(!job) return 0 if(jobban_isbanned(player, rank)) return 0 + if(!job.player_old_enough(player.client)) return 0 var/position_limit = job.total_positions if(!latejoin) position_limit = job.spawn_positions @@ -65,6 +66,9 @@ var/global/datum/controller/occupations/job_master if(jobban_isbanned(player, job.title)) Debug("FOC isbanned failed, Player: [player]") continue + if(!job.player_old_enough(player.client)) + Debug("FOC player not old enough, Player: [player]") + continue if(flag && (!player.client.prefs.be_special & flag)) Debug("FOC flag failed, Player: [player], Flag: [flag], ") continue @@ -74,7 +78,7 @@ var/global/datum/controller/occupations/job_master return candidates proc/GiveRandomJob(var/mob/new_player/player) - Debug("FOC Giving random job, Player: [player]") + Debug("GRJ Giving random job, Player: [player]") for(var/datum/job/job in shuffle(occupations)) if(!job) continue @@ -86,11 +90,15 @@ var/global/datum/controller/occupations/job_master continue if(jobban_isbanned(player, job.title)) - Debug("FOC isbanned failed, Player: [player], Job: [job.title]") + Debug("GRJ isbanned failed, Player: [player], Job: [job.title]") + continue + + if(!job.player_old_enough(player.client)) + Debug("GRJ player not old enough, Player: [player]") continue if((job.current_positions < job.spawn_positions) || job.spawn_positions == -1) - Debug("FOC Random job given, Player: [player], Job: [job]") + Debug("GRJ Random job given, Player: [player], Job: [job]") AssignRole(player, job.title) unassigned -= player break @@ -233,7 +241,11 @@ var/global/datum/controller/occupations/job_master continue if(jobban_isbanned(player, job.title)) - Debug("FOC isbanned failed, Player: [player], Job:[job.title]") + Debug("DO isbanned failed, Player: [player], Job:[job.title]") + continue + + if(!job.player_old_enough(player.client)) + Debug("DO player not old enough, Player: [player], Job:[job.title]") continue // If the player wants that job on this level, then try give it to him. @@ -241,7 +253,7 @@ var/global/datum/controller/occupations/job_master // If the job isn't filled if((job.current_positions < job.spawn_positions) || job.spawn_positions == -1) - Debug("FOC pass, Player: [player], Level:[level], Job:[job.title]") + Debug("DO pass, Player: [player], Level:[level], Job:[job.title]") AssignRole(player, job.title) unassigned -= player break @@ -417,12 +429,16 @@ var/global/datum/controller/occupations/job_master var/level3 = 0 //low var/level4 = 0 //never var/level5 = 0 //banned + var/level6 = 0 //account too young for(var/mob/new_player/player in player_list) if(!(player.ready && player.mind && !player.mind.assigned_role)) continue //This player is not ready if(jobban_isbanned(player, job.title)) level5++ continue + if(!job.player_old_enough(player.client)) + level6++ + continue if(player.client.prefs.GetJobDepartment(job, 1) & job.flag) level1++ else if(player.client.prefs.GetJobDepartment(job, 2) & job.flag) @@ -431,5 +447,5 @@ var/global/datum/controller/occupations/job_master level3++ else level4++ //not selected - tmp_str += "HIGH=[level1]|MEDIUM=[level2]|LOW=[level3]|NEVER=[level4]|BANNED=[level5]|-" + tmp_str += "HIGH=[level1]|MEDIUM=[level2]|LOW=[level3]|NEVER=[level4]|BANNED=[level5]|-|YOUNG=[level6]|-" feedback_add_details("job_preferences",tmp_str) diff --git a/code/game/jobs/jobprocs.dm b/code/game/jobs/jobprocs.dm index cbe4587c7e..60b8c6a99d 100644 --- a/code/game/jobs/jobprocs.dm +++ b/code/game/jobs/jobprocs.dm @@ -63,4 +63,4 @@ H << "You'll have to wait if you want to atone for your sins." spawn(3000) H.miming = 1 - return + return \ No newline at end of file diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index 0977ac861e..3ef743c60b 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -31,4 +31,9 @@ control_freak = 1 - + //////////////////////////////////// + //things that require the database// + //////////////////////////////////// + var/player_age = "Requires database" //So admins know why it isn't working - Used to determine how old the account is - in days. + var/related_accounts_ip = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this ip + var/related_accounts_cid = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this computer id diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 967220298e..a76ef035c4 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -157,11 +157,26 @@ var/sql_ckey = sql_sanitize_text(src.ckey) - var/DBQuery/query = dbcon.NewQuery("SELECT id FROM erro_player WHERE ckey = '[sql_ckey]'") + var/DBQuery/query = dbcon.NewQuery("SELECT id, datediff(Now(),firstseen) as age FROM erro_player WHERE ckey = '[sql_ckey]'") query.Execute() var/sql_id = 0 while(query.NextRow()) sql_id = query.item[1] + player_age = text2num(query.item[2]) + break + + var/DBQuery/query_ip = dbcon.NewQuery("SELECT ckey FROM erro_player WHERE ip = '[address]'") + query_ip.Execute() + related_accounts_ip = "" + while(query_ip.NextRow()) + related_accounts_ip += "[query_ip.item[1]], " + break + + var/DBQuery/query_cid = dbcon.NewQuery("SELECT ckey FROM erro_player WHERE computerid = '[computer_id]'") + query_cid.Execute() + related_accounts_cid = "" + while(query_cid.NextRow()) + related_accounts_cid += "[query_cid.item[1]], " break //Just the standard check to see if it's actually a number @@ -189,6 +204,12 @@ var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO erro_player (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, '[sql_ckey]', Now(), Now(), '[sql_ip]', '[sql_computerid]', '[sql_admin_rank]')") query_insert.Execute() + //Logging player access + var/serverip = "[world.internet_address]:[world.port]" + var/DBQuery/query_accesslog = dbcon.NewQuery("INSERT INTO `erro_connection_log`(`id`,`datetime`,`serverip`,`ckey`,`ip`,`computerid`) VALUES(null,Now(),'[serverip]','[sql_ckey]','[sql_ip]','[sql_computerid]');") + query_accesslog.Execute() + + #undef TOPIC_SPAM_DELAY #undef UPLOAD_LIMIT #undef MIN_CLIENT_VERSION diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 6f497a2a45..63fc4743d4 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -247,6 +247,10 @@ datum/preferences if(jobban_isbanned(user, rank)) HTML += "[rank] \[BANNED]" 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]" + continue if((job_civilian_low & ASSISTANT) && (rank != "Assistant")) HTML += "[rank]" continue diff --git a/code/modules/destilery/main.dm b/code/modules/destilery/main.dm index b1e00a29d2..1ce22ef909 100644 --- a/code/modules/destilery/main.dm +++ b/code/modules/destilery/main.dm @@ -288,6 +288,3 @@ enzymes -= 50 new/obj/item/weapon/reagent_containers/food/condiment/enzyme(src.loc) - // /obj/item/weapon/reagent_containers/food/condiment/enzyme - - diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 077c79bfc9..92c0e6ec87 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -239,6 +239,7 @@ if(!job) return 0 if((job.current_positions >= job.total_positions) && job.total_positions != -1) return 0 if(jobban_isbanned(src,rank)) return 0 + if(!job.player_old_enough(src.client)) return 0 return 1 diff --git a/config/config.txt b/config/config.txt index 559844f6c0..caf1e968fb 100644 --- a/config/config.txt +++ b/config/config.txt @@ -18,6 +18,13 @@ BAN_LEGACY_SYSTEM ## Add a # here if you wish to use the setup where jobs have more access. This is intended for servers with low populations - where there are not enough players to fill all roles, so players need to do more than just one job. Also for servers where they don't want people to hide in their own departments. JOBS_HAVE_MINIMAL_ACCESS +## Unhash this entry to have certain jobs require your account to be at least a certain number of days old to select. You can configure the exact age requirement for different jobs by editing +## the minimal_player_age variable in the files in folder /code/game/jobs/job/.. for the job you want to edit. Set minimal_player_age to 0 to disable age requirement for that job. +## REQUIRES the database set up to work. Keep it hashed if you don't have a database set up. +## NOTE: If you have just set-up the database keep this DISABLED, as player age is determined from the first time they connect to the server with the database up. If you just set it up, it means +## 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 + ## log OOC channel LOG_OOC