diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 1fbf4b5e8d0..350a1ea839d 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 a514f31f9db..436d1485e76 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 50fbf626dab..cc4750fa413 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 7914690d500..78b3d755c31 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 73a7ea1198f..c360852c2cc 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 19ddab7834b..faf4c36648a 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 1e2b90ef991..b722b0ccb52 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 aac58091416..853f198953a 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 465ef7f6496..40110fd3540 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 cbe4587c7e1..60b8c6a99df 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 0977ac861e1..3ef743c60b8 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 967220298e4..a76ef035c4a 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 6f497a2a45d..63fc4743d40 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]