<commit_before>/*
 * Copyright  2014 <NAME>
 * Distributed under the GNU Affero General Public License, version 3.
 * Your changes must be made public.
 * For the full license text, see LICENSE.txt.
 */
mob/Player/var/ror=0

var/list/mob/Player/Players = list()
turf/var/flyblock=0

turf
	Enter(atom/movable/O)
		if(ismob(O))
			if(flyblock==2)
				for(var/atom/A in src)
					if(A.density) return 0
				return ..()
			if(!density) return ..()
			if(O:Gm && !O:flying) return ..()
			if(!O:key) return ..()
			else if(density&&flyblock)
				return 0
		return ..()
proc/str_count(haystack, needle)
	. = 0
	var/i = 1
	for(i; i <= length(haystack); i++)
		if(copytext(haystack, i, i + length(needle)) == needle)	.++

client
	mouse_pointer_icon='pointer.dmi'
#include <deadron/basecamp>
#define BASE_MENU_CREATE_CHARACTER	"Create New Character"
#define BASE_MENU_DELETE_CHARACTER	"Delete Character"
#define BASE_MENU_CANCEL			"Cancel"
#define BASE_MENU_QUIT				"Quit"
world/cache_lifespan = 0

mob/Player/var/lastreadDP

var/WorldData/worldData

WorldData
	var
		list
			playersData
			expScoreboard
			competitiveBans
			prizeItems
			DP
			housepointsGSRH
			DJs
			dp_editors
			stories
			ministrybanlist
			mailTracker
			auctionItems
			spellsHistory

			vault/globalvaults
			customMap/customMaps
			Gms

		elderWand
		canReadBooks = 1
		allowGifts   = 1
		dplastupdate
		housecupwinner

		ministrypw    = "ketchup"
		ministrybank  = 0
		taxrate       = 15
		GMSchedule

		tmp
			lastusedAFKCheck
			ministryopen

proc
	Load_World()
		var/savefile/X = new ("players/World.sav")

		X["worldData"] >> worldData
		if(!worldData) worldData = new

		if(!worldData.spellsHistory)
			worldData.spellsHistory = list()

		if(!worldData.ministrybanlist)
			worldData.ministrybanlist = new/list()
		//X["promicons"] >> promicons
		if(!promicons) promicons = list()
		if(!worldData.customMaps) worldData.customMaps = list()
		if(!worldData.globalvaults) worldData.globalvaults = list()
		if(!worldData.DP)
			worldData.DP = new/list()
		if(!worldData.housepointsGSRH)
			worldData.housepointsGSRH = new/list(4)
			worldData.housepointsGSRH[1] = 0
			worldData.housepointsGSRH[2] = 0
			worldData.housepointsGSRH[3] = 0
			worldData.housepointsGSRH[4] = 0

		var/list/cw
		X["ClanWars"] >> cw
		if(cw && cw.len)
			spawn()
				for(var/c in cw)
					if(!(c in clanwars_schedule))
						var/list/l = splittext(c, " - ")
						add_clan_wars(l[1], l[2])

		var/list/classes
		X["AutoClasses"] >> classes
		if(classes && classes.len)
			spawn()
				for(var/class in classes)
					if(!(class in autoclass_schedule))
						var/list/l = splittext(class, " - ")
						add_autoclass(l[1], l[2])

	Save_World()
		fdel("players/World.sav")
		var/savefile/X = new("players/World.sav")
		//var/list/objs=list()

		var/list/cw = list()
		for(var/e in clanwars_schedule)
			cw += e

		var/list/classes = list()
		for(var/e in autoclass_schedule)
			classes += e

		X["worldData"] << worldData
		X["ClanWars"] << cw
		X["AutoClasses"] << classes

world/Del()
	Save_World()
	SwapMaps_Save_All()

client/var/tmp
	base_num_characters_allowed = 1
	base_autoload_character = 0
	base_autosave_character = 1
	base_autodelete_mob = 1
	base_save_verbs = 1
obj/stackobj/Write(savefile/F)
	return

mob/Player/base_save_allowed = 1
mob
	var/tmp
		base_save_allowed = 0
		base_save_location = 1

		save_loaded = FALSE

	var/list/base_saved_verbs

	proc/base_InitFromSavefile()
		return


	Write(savefile/F)

		..()
		if(src.type != /mob/Player)
			return
		F["overlays"] << null
		F["icon"] << null
		F["underlays"] << null
		F["savefileversion"] << SAVEFILE_VERSION
		if (base_save_location && world.maxx)
			F["last_x"] << x
			F["last_y"] << y
			F["last_z"] << z
		F["UsedKeys"] << src:saveSpells()

	Read(savefile/F)
		var/testtype
		F["type"] >> testtype
		if(testtype == /mob/create_character)
			F["type"] << /mob/Player
			return
		//F["key"] << null
		saveError = 0
		..()
		if(testtype != /mob/Player)
			return
		if (base_save_location && world.maxx)
			var/mob/Player/p = src
			var/last_x
			var/last_y
			var/last_z
			F["last_x"] >> last_x
			F["last_y"] >> last_y
			F["last_z"] >> last_z
			F["UsedKeys"] >> src:UsedKeys
			if(saveError == 0)
				save_loaded = TRUE
			var/savefile_version
			F["savefileversion"] >> savefile_version
			if(!savefile_version) savefile_version = 3

			if(savefile_version < 17)
				var/gold/g = new
				if(isnum(gold))
					g.change(bronze=gold)
				if(isnum(goldinbank))
					g.change(bronze=goldinbank)
				g.give(src)
				gold       = null
				goldinbank = null

			if(savefile_version < 22)
				spawn()
					verbs -= /mob/GM/verb/Auror_chat
					verbs -= /mob/GM/verb/Auror_Robes
					verbs -= /mob/GM/verb/DErobes
					verbs -= /mob/GM/verb/DE_chat
					verbs -= /mob/GM/verb/Clan_store
					verbs -= /mob/Spells/verb/Morsmordre

			if(savefile_version < 23)
				for(var/obj/items/i in src)
					if(istype(i, /obj/items/ingredients/daisy) || istype(i, /obj/items/ingredients/aconite) || istype(i, /obj/items/food))
						i.Dispose()

			if(savefile_version < 24)
				p.GMFrozen = 0

			if(savefile_version < 26)

				var/turf/t = locate("@DiagonAlley")
				last_x = t.x
				last_y = t.y
				last_z = t.z

				src << errormsg("Your entire gold savings was converted to the new currency coins, this includes your banked gold, make sure to drop your currency coins at your vault to avoid any loss.")

				if(gold)
					var/gold/g = new
					g.plat   = gold.plat   + goldinbank.plat
					g.gold   = gold.gold   + goldinbank.gold
					g.silver = gold.silver + goldinbank.silver
					g.bronze = gold.bronze + goldinbank.bronze

					g.sort()
					g.give(src)

					gold = null
					goldinbank = null

				var/amount = 0
				for(var/obj/items/artifact/a in src)
					amount += a.stack
					a.loc = null

				if(amount)
					var/obj/items/artifact/a = new (src)
					a.stack = amount
					a.UpdateDisplay()

				var/obj/items/wearable/invisibility_cloak/cloak = locate() in p.Lwearing
				if(cloak)
					cloak.Equip(p, 1, 1)

				for(var/obj/items/wearable/invisibility_cloak/c in src)
					c.loc = null

				p.Resort_Stacking_Inv()

				p.refundSpells3()

			if(savefile_version < 27)
				gold = null
				goldinbank = null

			if(savefile_version < 29)
				var/obj/items/wearable/invisibility_cloak/cloak = locate() in p.Lwearing
				if(cloak)
					cloak.Equip(p, 1, 1)
					cloak.loc = null

			if(savefile_version < 30)
				p.MMP = 200
				p.MP = 200
				p.level = 1
				p.resetStatPoints()
				spawn()
					if(p.client.tmpInterface)
						p.Interface = p.client.tmpInterface
						p.Interface.Init(p)

					for(var/s in p.questPointers)
						if(s == "Brother Trouble") continue
						if(s == "Brewing Practice") continue
						if(s == "Sweet Easter") continue
						if(s == "PvP Introduction") continue
						if(s == "Culling the Herd") continue
						if(s == "Strength of Dragons") continue
						if(s == "Make a Potion") continue
						if(s == "Make a Fortune") continue
						if(s == "Make a Spell") continue
						if(s == "Make a Wig") continue
						if(s == "On House Arrest") continue

						p.questPointers -= s

					p.startQuest("Tutorial: The Wand Maker")

					for(var/obj/items/reputation/r in p)
						r.loc = null

					for(var/obj/items/wearable/w in p)
						if(istype(w, /obj/items/wearable/orb) || istype(w, /obj/items/wearable/title) || istype(w, /obj/items/wearable/magic_eye) || istype(w, /obj/items/wearable/halloween_bucket))
							w.Equip(p, 1, 1)
							w.loc = null
						else
							if(w.quality > 0)
								w.quality = 0
								w.bonus &= ~3

								var/list/split = splittext(w.name, " +")

								w.name = split[1]

							if(istype(w, /obj/items/wearable/wands))
								w:exp = 0
								w:projColor = null
							if(istype(w, /obj/items/wearable/pets))
								w:exp = 0


					p.verbs -= typesof(/mob/Spells/verb/)
					p.verbs += new/mob/Spells/verb/Inflamari
					p.spellpoints = 0

					p.Fire  = new("Fire")
					p.Earth = new("Earth")
					p.Water = new("Water")
					p.Ghost = new("Ghost")

					p << infomsg("The majority of your quests, your spells, level and any stat bonuses from items had were wiped, the rest of your wealth is untouched.")

			if(last_z >= SWAPMAP_Z && !worldData.currentMatches.isReconnect(src) && worldData.sandboxZ != last_z) //If player is on a swap map, move them to gringotts
				loc = locate("leavevault")
			else
				var/turf/t = locate(last_x, last_y, last_z)
				if(!t || t.name == "blankturf")
					loc = locate("@Hogwarts")
				else
					if(!worldData.playersData) worldData.playersData = list()

					var/guild/g
					var/PlayerData/data = worldData.playersData[ckey]
					if(data)
						g = data.guild

					if((istype(t.loc, /area/DEHQ) || istype(t.loc, /area/safezone/DEHQ)) && worldData.majorChaos != g)
						loc = locate("@Hogwarts")
					else if((istype(t.loc, /area/AurorHQ) || istype(t.loc, /area/safezone/AurorHQ)) && worldData.majorPeace != g)
						loc = locate("@Hogwarts")
					else
						loc = t

			spawn()
				if(p.loc && p.loc.loc)
					p.loc.loc.Enter(usr)
			if(p.ror==0)
				var/rorrand=rand(1,3)
				p.ror=rorrand
			p.icon_state = ""
			if(p.Gm)
				if(p.Gender == "Female")
					p.icon = 'FemaleStaff.dmi'
				else
					p.icon = 'MaleStaff.dmi'
			else
				if(p.Gender == "Male")
					switch(p.House)
						if("Gryffindor")
							p.icon = 'MaleGryffindor.dmi'
							p.verbs += /mob/GM/verb/Gryffindor_Chat
						if("Ravenclaw")
							p.icon = 'MaleRavenclaw.dmi'
							p.verbs += /mob/GM/verb/Ravenclaw_Chat
						if("Slytherin")
							p.icon = 'MaleSlytherin.dmi'
							p.verbs += /mob/GM/verb/Slytherin_Chat
						if("Hufflepuff")
							p.icon = 'MaleHufflepuff.dmi'
							p.verbs += /mob/GM/verb/Hufflepuff_Chat
						if("Ministry")
							p.icon = 'suit.dmi'
				else if(p.Gender == "Female")
					switch(p.House)
						if("Gryffindor")
							p.icon = 'FemaleGryffindor.dmi'
							p.verbs += /mob/GM/verb/Gryffindor_Chat
						if("Ravenclaw")
							p.icon = 'FemaleRavenclaw.dmi'
							p.verbs += /mob/GM/verb/Ravenclaw_Chat
						if("Slytherin")
							p.icon = 'FemaleSlytherin.dmi'
							p.verbs += /mob/GM/verb/Slytherin_Chat
						if("Hufflepuff")
							p.icon = 'FemaleHufflepuff.dmi'
							p.verbs += /mob/GM/verb/Hufflepuff_Chat
						if("Ministry")
							p.icon = 'suit.dmi'
			p.baseicon = p.icon
			if(client)
				for(var/mob/Player/c in Players)
					if(c.Gm)
						c <<"<b><i>[src][refererckey == c.client.ckey ? "(referral)" : ""] ([client.address])([ckey])([client.connection == "web" ? "webclient" : "dreamseeker"]) logged in.</i></b>"
					else
						c <<"<b><i>[src][refererckey == c.client.ckey ? "(referral)" : ""] logged in.</i></b>"
				p<<browse(rules,"window=1;size=500x400")
				src<<"<b><span style=\"font-size:2; color:#3636F5;\">Welcome to Harry Potter: The Wizards Chronicles</span> <u><a href='http://wizardschronicles.com/?ver=[VERSION]'>Version [VERSION]</a></u></b> <br>Visit the forums <a href=\"http://www.wizardschronicles.com\">here.</a>"

				if(src:lastreadDP < worldData.dplastupdate)
					p << "<span style=\"color:red;\">The Daily Prophet has an issue that you haven't yet read. <a href='?src=\ref[src];action=daily_prophet'>Click here</a> to view.</span>"
				if(VERSION != p.lastversion)
					p.lastversion = VERSION
					src<<"<b><span style=\"font-size:2;\">TWC had an update since you last logged in! A list of changes can be found <a href='http://wizardschronicles.com/?ver=[VERSION]'>here.</a></span></b>"


mob/Player/var/lastversion
var/rules = file("rules.html")

mob/BaseCamp
	base_save_allowed = 0
	Login()
		RemoveVerbs()
		return

	Stat()
		return

	proc/RemoveVerbs()
		for (var/my_verb in verbs)
			verbs -= my_verb

mob/BaseCamp/FirstTimePlayer
	proc/FirstTimePlayer()
		return 1

world
	mob = /mob/BaseCamp/ChoosingCharacter
/*var/HTML/HTML
var/HTMLres = list('logo_banner.png', 'logo.png', 'mainstyle.css')
mob/BaseCamp/ChoosingCharacter/Topic(href,href_list[])
	switch(href_list["action"])
		if("loginLoad")
			if(istype(src,/mob/BaseCamp/ChoosingCharacter))
				Choose_Character()
		if("loginNew")
			if(istype(src,/mob/BaseCamp/ChoosingCharacter))
				New_Character()

client/Topic(href,href_list[],hsrc)
	..()
	switch(href_list["action"])
		if("login")
			if(href_list["btnregister"])
				usr << output(HTMLOutput(usr,"register",href_list),"broLogin")
		if("register")
			if(href_list["btncancel"])
				usr << output(HTMLOutput(usr,"login",href_list),"broLogin")
				return
			if(length(href_list["emailaddress"]) < 6\
			|| length(href_list["emailaddress"]) > 60\
			|| !findtext(href_list["emailaddress"],"@"))
				href_list["error"] = "Invalid email address entered."
			else if(!cmptext(href_list["emailaddress"],href_list["emailaddressconfirm"]))
				href_list["error"] = "Email addresses don't match."

			else if(length(href_list["password"]) < 5\
			|| length(href_list["password"]) > 60)
				href_list["error"] = "Password must be between 5 and 60 characters in length."
			else if(!cmptext(href_list["password"],href_list["passwordconfirm"]))
				href_list["error"] = "Passwords don't match."
			if(href_list["error"])
				usr << output(HTMLOutput(usr,"register",href_list),"broLogin")
proc/HTMLOutput(mob/M,page,list/href_list)
	//for(var/res in HTMLres)
	//	M << browse_rsc(res)
	switch(page)
		if("login")
			return {"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="mainstyle.css" />
</head>
<body>
	<div id="centerwrapper">
		<div style="margin-left:auto;margin-right:auto;width: 700px;height: 300px">
			<div style="float: left;width:263px;">
				<img src="silver_logo.jpg" />
			</div>
			<div style="text-align:right;padding-top:40px;">
			<form action="byond://" method="get">
				<label for="emailaddress">Email Address:</label><input id="emailaddress" name="emailaddress" /><br />
				<label for="password">Password:</label><input id="password" name="password" type="password" /><br />
				<input id="remember" type="checkbox" /><label for="remember">Remember login email</label>
				<br />
				<input type="button" name="btnregister" value="Register" style="width:100px;margin-right:3px;" onclick="window.location='?action=login;btnregister=1'" /><input type="submit" value="Login" style="width:100px;" />
				<input type="hidden" name="action" value="login" />
				<br />
				[href_list ? "<span class=\"error\">[href_list["error"]]</span>":]
			</form>
			</div><div style="clear: both"></div>
		</div>
	</div>
</body>
</html>"}
		if("register")
			return {"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="mainstyle.css" />
</head>
<body>
	<div id="centerwrapper">
		<div style="margin-left:auto;margin-right:auto;width: 700px;height: 300px">
			<div style="float: left;width:263px;">
				<img src="silver_logo.jpg" />
			</div>
			<div style="text-align:right;padding-top:30px;">
			<form action="byond://" method="get">
				<label for="emailaddress">Email Address:</label><input id="emailaddress" name="emailaddress" /><br />
				<label for="emailaddressconfirm">Confirm Email Address:</label><input id="emailaddressconfirm" name="emailaddressconfirm" /><br />
				<br />
				<label for="password">Password:</label><input id="password" name="password" type="password" /><br />
				<label for="passwordconfirm">Confirm Password:</label><input id="passwordconfirm" name="passwordconfirm" type="password" /><br />
				<br />
				<input type="button" name="btncancel" value="Cancel" style="width:100px;margin-right:3px;" onclick="window.location='?action=register;btncancel=1'" /><input type="submit" value="Register" style="width:100px;" />
				<input type="hidden" name="action" value="register" />
				<br />
				[href_list ? "<span class=\"error\">[href_list["error"]]</span>":]
			</form>
			</div><div style="clear: both"></div>
		</div>
	</div>
</body>
</html>"}
	return {"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="http://wizardschronicles.com/login/mainstyle.css" />
</head>
<body onresize="hideDiv()">
		<div id="banner">
			<img src="http://wizardschronicles.com/login/logo_banner.png" />
		</div>
		<div id="logo">
			<img src="http://wizardschronicles.com/login/logo.png" />
		</div>
		<div id="main">
				<ul class="centered-ul">
					<li class="horizontal-li"><a href="?src=\ref[M];action=loginNew">New</a></li>
					<li class="horizontal-li"> - </li>
					<li class="horizontal-li"><a href="?src=\ref[M];action=loginLoad">Load</li>
				</ul>
		</div>

	<script language=javascript type='text/javascript'>
		var swap = false;
		hideDiv();
		function hideDiv()
		{
			if(document.documentElement.offsetHeight < 480 && !swap)
			{
				swapNodes(document.getElementById('logo'), document.getElementById('main'));
				swap = true;
			}
			else if(document.documentElement.offsetHeight >= 480 && swap)
			{
 				swapNodes(document.getElementById('logo'), document.getElementById('main'));
				swap = false;
			}
		}

		function swapNodes(node1, node2)
		{
    		node2_copy = node2.cloneNode(true);
    		node1.parentNode.insertBefore(node2_copy, node1);
    		node2.parentNode.insertBefore(node1, node2);
    		node2.parentNode.replaceChild(node2, node2_copy);
		}
	</script>
</body>
</html>"}
*/
client/var/tmp/interface/tmpInterface

hudobj
	login
		anchor_x = "CENTER"
		anchor_y = "CENTER"

		mouse_opacity = 2

		icon = 'Login Stone.dmi'
		icon_state = "moss"

		appearance_flags = PIXEL_SCALE

		MouseEntered()
			transform *= 1.25
		MouseExited()
			transform = null


		Load
			maptext = "<b><span style=\"font-size:14px;color:#34d\">Load</span></b>"
			maptext_width = 64
			maptext_x = 9
			maptext_y = 4

			screen_x = 64

			Click()
				if(istype(usr,/mob/BaseCamp/ChoosingCharacter))
					usr:Choose_Character()

		New
			maptext = "<b><span style=\"font-size:14px;color:#34d\">New</span></b>"
			maptext_width = 64
			maptext_x = 10
			maptext_y = 4

			screen_x = -94

			Click()
				if(istype(usr,/mob/BaseCamp/ChoosingCharacter))
					usr:New_Character()

obj/loginCamera
	mouse_opacity = 0
	invisibility = 10
	glide_size = 8

	New()
		..()
		tag = "loginCamera"
		wander()

	proc/wander()
		set waitfor = 0
		var/turf/target
		while(src)
			if(!target || loc == target)
				target = locate(rand(50,70), rand(25,85), z)

			var/turf/t = get_step_towards(loc, target)
			if(t)
				loc = t
			else
				target = null
			sleep(4)


mob/tmpmob
mob/BaseCamp/ChoosingCharacter
	Login()
		client.initMapBrowser()
		new /hudobj/login/New(null, client, null, 1)
		new /hudobj/login/Load(null, client, null, 1)

		client.tmpInterface = new (client)
		client.onResize(60, 31, 0, 0, 1)

		var/obj/o = locate("loginCamera")
		client.eye = o
		client.perspective = EYE_PERSPECTIVE

	//	usr << output(HTMLOutput(src),"broLogin")
		/*var/first_initial = copytext(ckey, 1, 2)
		if(fexists("players/[first_initial]/[ckey].sav"))
			var/mob/tmpmob/A
			var/mob/tmpmob/M = new()
			var/savefile/S = new("players/[first_initial]/[ckey].sav")
			S.cd = "/players/[ckey]/mobs/"
			var/firstentry
			for (var/entry in S)
				S["[entry]/mob"] >> M
				//M = S["[entry]/mob"]The nurse orbs out
				break<commit_msg>Allows players on login to see through opacity<commit_after>/*
 * Copyright  2014 <NAME>
 * Distributed under the GNU Affero General Public License, version 3.
 * Your changes must be made public.
 * For the full license text, see LICENSE.txt.
 */
mob/Player/var/ror=0

var/list/mob/Player/Players = list()
turf/var/flyblock=0

turf
	Enter(atom/movable/O)
		if(ismob(O))
			if(flyblock==2)
				for(var/atom/A in src)
					if(A.density) return 0
				return ..()
			if(!density) return ..()
			if(O:Gm && !O:flying) return ..()
			if(!O:key) return ..()
			else if(density&&flyblock)
				return 0
		return ..()
proc/str_count(haystack, needle)
	. = 0
	var/i = 1
	for(i; i <= length(haystack); i++)
		if(copytext(haystack, i, i + length(needle)) == needle)	.++

client
	mouse_pointer_icon='pointer.dmi'
#include <deadron/basecamp>
#define BASE_MENU_CREATE_CHARACTER	"Create New Character"
#define BASE_MENU_DELETE_CHARACTER	"Delete Character"
#define BASE_MENU_CANCEL			"Cancel"
#define BASE_MENU_QUIT				"Quit"
world/cache_lifespan = 0

mob/Player/var/lastreadDP

var/WorldData/worldData

WorldData
	var
		list
			playersData
			expScoreboard
			competitiveBans
			prizeItems
			DP
			housepointsGSRH
			DJs
			dp_editors
			stories
			ministrybanlist
			mailTracker
			auctionItems
			spellsHistory

			vault/globalvaults
			customMap/customMaps
			Gms

		elderWand
		canReadBooks = 1
		allowGifts   = 1
		dplastupdate
		housecupwinner

		ministrypw    = "ketchup"
		ministrybank  = 0
		taxrate       = 15
		GMSchedule

		tmp
			lastusedAFKCheck
			ministryopen

proc
	Load_World()
		var/savefile/X = new ("players/World.sav")

		X["worldData"] >> worldData
		if(!worldData) worldData = new

		if(!worldData.spellsHistory)
			worldData.spellsHistory = list()

		if(!worldData.ministrybanlist)
			worldData.ministrybanlist = new/list()
		//X["promicons"] >> promicons
		if(!promicons) promicons = list()
		if(!worldData.customMaps) worldData.customMaps = list()
		if(!worldData.globalvaults) worldData.globalvaults = list()
		if(!worldData.DP)
			worldData.DP = new/list()
		if(!worldData.housepointsGSRH)
			worldData.housepointsGSRH = new/list(4)
			worldData.housepointsGSRH[1] = 0
			worldData.housepointsGSRH[2] = 0
			worldData.housepointsGSRH[3] = 0
			worldData.housepointsGSRH[4] = 0

		var/list/cw
		X["ClanWars"] >> cw
		if(cw && cw.len)
			spawn()
				for(var/c in cw)
					if(!(c in clanwars_schedule))
						var/list/l = splittext(c, " - ")
						add_clan_wars(l[1], l[2])

		var/list/classes
		X["AutoClasses"] >> classes
		if(classes && classes.len)
			spawn()
				for(var/class in classes)
					if(!(class in autoclass_schedule))
						var/list/l = splittext(class, " - ")
						add_autoclass(l[1], l[2])

	Save_World()
		fdel("players/World.sav")
		var/savefile/X = new("players/World.sav")
		//var/list/objs=list()

		var/list/cw = list()
		for(var/e in clanwars_schedule)
			cw += e

		var/list/classes = list()
		for(var/e in autoclass_schedule)
			classes += e

		X["worldData"] << worldData
		X["ClanWars"] << cw
		X["AutoClasses"] << classes

world/Del()
	Save_World()
	SwapMaps_Save_All()

client/var/tmp
	base_num_characters_allowed = 1
	base_autoload_character = 0
	base_autosave_character = 1
	base_autodelete_mob = 1
	base_save_verbs = 1
obj/stackobj/Write(savefile/F)
	return

mob/Player/base_save_allowed = 1
mob
	var/tmp
		base_save_allowed = 0
		base_save_location = 1

		save_loaded = FALSE

	var/list/base_saved_verbs

	proc/base_InitFromSavefile()
		return


	Write(savefile/F)

		..()
		if(src.type != /mob/Player)
			return
		F["overlays"] << null
		F["icon"] << null
		F["underlays"] << null
		F["savefileversion"] << SAVEFILE_VERSION
		if (base_save_location && world.maxx)
			F["last_x"] << x
			F["last_y"] << y
			F["last_z"] << z
		F["UsedKeys"] << src:saveSpells()

	Read(savefile/F)
		var/testtype
		F["type"] >> testtype
		if(testtype == /mob/create_character)
			F["type"] << /mob/Player
			return
		//F["key"] << null
		saveError = 0
		..()
		if(testtype != /mob/Player)
			return
		if (base_save_location && world.maxx)
			var/mob/Player/p = src
			var/last_x
			var/last_y
			var/last_z
			F["last_x"] >> last_x
			F["last_y"] >> last_y
			F["last_z"] >> last_z
			F["UsedKeys"] >> src:UsedKeys
			if(saveError == 0)
				save_loaded = TRUE
			var/savefile_version
			F["savefileversion"] >> savefile_version
			if(!savefile_version) savefile_version = 3

			if(savefile_version < 17)
				var/gold/g = new
				if(isnum(gold))
					g.change(bronze=gold)
				if(isnum(goldinbank))
					g.change(bronze=goldinbank)
				g.give(src)
				gold       = null
				goldinbank = null

			if(savefile_version < 22)
				spawn()
					verbs -= /mob/GM/verb/Auror_chat
					verbs -= /mob/GM/verb/Auror_Robes
					verbs -= /mob/GM/verb/DErobes
					verbs -= /mob/GM/verb/DE_chat
					verbs -= /mob/GM/verb/Clan_store
					verbs -= /mob/Spells/verb/Morsmordre

			if(savefile_version < 23)
				for(var/obj/items/i in src)
					if(istype(i, /obj/items/ingredients/daisy) || istype(i, /obj/items/ingredients/aconite) || istype(i, /obj/items/food))
						i.Dispose()

			if(savefile_version < 24)
				p.GMFrozen = 0

			if(savefile_version < 26)

				var/turf/t = locate("@DiagonAlley")
				last_x = t.x
				last_y = t.y
				last_z = t.z

				src << errormsg("Your entire gold savings was converted to the new currency coins, this includes your banked gold, make sure to drop your currency coins at your vault to avoid any loss.")

				if(gold)
					var/gold/g = new
					g.plat   = gold.plat   + goldinbank.plat
					g.gold   = gold.gold   + goldinbank.gold
					g.silver = gold.silver + goldinbank.silver
					g.bronze = gold.bronze + goldinbank.bronze

					g.sort()
					g.give(src)

					gold = null
					goldinbank = null

				var/amount = 0
				for(var/obj/items/artifact/a in src)
					amount += a.stack
					a.loc = null

				if(amount)
					var/obj/items/artifact/a = new (src)
					a.stack = amount
					a.UpdateDisplay()

				var/obj/items/wearable/invisibility_cloak/cloak = locate() in p.Lwearing
				if(cloak)
					cloak.Equip(p, 1, 1)

				for(var/obj/items/wearable/invisibility_cloak/c in src)
					c.loc = null

				p.Resort_Stacking_Inv()

				p.refundSpells3()

			if(savefile_version < 27)
				gold = null
				goldinbank = null

			if(savefile_version < 29)
				var/obj/items/wearable/invisibility_cloak/cloak = locate() in p.Lwearing
				if(cloak)
					cloak.Equip(p, 1, 1)
					cloak.loc = null

			if(savefile_version < 30)
				p.MMP = 200
				p.MP = 200
				p.level = 1
				p.resetStatPoints()
				spawn()
					if(p.client.tmpInterface)
						p.Interface = p.client.tmpInterface
						p.Interface.Init(p)

					for(var/s in p.questPointers)
						if(s == "Brother Trouble") continue
						if(s == "Brewing Practice") continue
						if(s == "Sweet Easter") continue
						if(s == "PvP Introduction") continue
						if(s == "Culling the Herd") continue
						if(s == "Strength of Dragons") continue
						if(s == "Make a Potion") continue
						if(s == "Make a Fortune") continue
						if(s == "Make a Spell") continue
						if(s == "Make a Wig") continue
						if(s == "On House Arrest") continue

						p.questPointers -= s

					p.startQuest("Tutorial: The Wand Maker")

					for(var/obj/items/reputation/r in p)
						r.loc = null

					for(var/obj/items/wearable/w in p)
						if(istype(w, /obj/items/wearable/orb) || istype(w, /obj/items/wearable/title) || istype(w, /obj/items/wearable/magic_eye) || istype(w, /obj/items/wearable/halloween_bucket))
							w.Equip(p, 1, 1)
							w.loc = null
						else
							if(w.quality > 0)
								w.quality = 0
								w.bonus &= ~3

								var/list/split = splittext(w.name, " +")

								w.name = split[1]

							if(istype(w, /obj/items/wearable/wands))
								w:exp = 0
								w:projColor = null
							if(istype(w, /obj/items/wearable/pets))
								w:exp = 0


					p.verbs -= typesof(/mob/Spells/verb/)
					p.verbs += new/mob/Spells/verb/Inflamari
					p.spellpoints = 0

					p.Fire  = new("Fire")
					p.Earth = new("Earth")
					p.Water = new("Water")
					p.Ghost = new("Ghost")

					p << infomsg("The majority of your quests, your spells, level and any stat bonuses from items had were wiped, the rest of your wealth is untouched.")

			if(last_z >= SWAPMAP_Z && !worldData.currentMatches.isReconnect(src) && worldData.sandboxZ != last_z) //If player is on a swap map, move them to gringotts
				loc = locate("leavevault")
			else
				var/turf/t = locate(last_x, last_y, last_z)
				if(!t || t.name == "blankturf")
					loc = locate("@Hogwarts")
				else
					if(!worldData.playersData) worldData.playersData = list()

					var/guild/g
					var/PlayerData/data = worldData.playersData[ckey]
					if(data)
						g = data.guild

					if((istype(t.loc, /area/DEHQ) || istype(t.loc, /area/safezone/DEHQ)) && worldData.majorChaos != g)
						loc = locate("@Hogwarts")
					else if((istype(t.loc, /area/AurorHQ) || istype(t.loc, /area/safezone/AurorHQ)) && worldData.majorPeace != g)
						loc = locate("@Hogwarts")
					else
						loc = t

			spawn()
				if(p.loc && p.loc.loc)
					p.loc.loc.Enter(usr)
			if(p.ror==0)
				var/rorrand=rand(1,3)
				p.ror=rorrand
			p.icon_state = ""
			if(p.Gm)
				if(p.Gender == "Female")
					p.icon = 'FemaleStaff.dmi'
				else
					p.icon = 'MaleStaff.dmi'
			else
				if(p.Gender == "Male")
					switch(p.House)
						if("Gryffindor")
							p.icon = 'MaleGryffindor.dmi'
							p.verbs += /mob/GM/verb/Gryffindor_Chat
						if("Ravenclaw")
							p.icon = 'MaleRavenclaw.dmi'
							p.verbs += /mob/GM/verb/Ravenclaw_Chat
						if("Slytherin")
							p.icon = 'MaleSlytherin.dmi'
							p.verbs += /mob/GM/verb/Slytherin_Chat
						if("Hufflepuff")
							p.icon = 'MaleHufflepuff.dmi'
							p.verbs += /mob/GM/verb/Hufflepuff_Chat
						if("Ministry")
							p.icon = 'suit.dmi'
				else if(p.Gender == "Female")
					switch(p.House)
						if("Gryffindor")
							p.icon = 'FemaleGryffindor.dmi'
							p.verbs += /mob/GM/verb/Gryffindor_Chat
						if("Ravenclaw")
							p.icon = 'FemaleRavenclaw.dmi'
							p.verbs += /mob/GM/verb/Ravenclaw_Chat
						if("Slytherin")
							p.icon = 'FemaleSlytherin.dmi'
							p.verbs += /mob/GM/verb/Slytherin_Chat
						if("Hufflepuff")
							p.icon = 'FemaleHufflepuff.dmi'
							p.verbs += /mob/GM/verb/Hufflepuff_Chat
						if("Ministry")
							p.icon = 'suit.dmi'
			p.baseicon = p.icon
			if(client)
				for(var/mob/Player/c in Players)
					if(c.Gm)
						c <<"<b><i>[src][refererckey == c.client.ckey ? "(referral)" : ""] ([client.address])([ckey])([client.connection == "web" ? "webclient" : "dreamseeker"]) logged in.</i></b>"
					else
						c <<"<b><i>[src][refererckey == c.client.ckey ? "(referral)" : ""] logged in.</i></b>"
				p<<browse(rules,"window=1;size=500x400")
				src<<"<b><span style=\"font-size:2; color:#3636F5;\">Welcome to Harry Potter: The Wizards Chronicles</span> <u><a href='http://wizardschronicles.com/?ver=[VERSION]'>Version [VERSION]</a></u></b> <br>Visit the forums <a href=\"http://www.wizardschronicles.com\">here.</a>"

				if(src:lastreadDP < worldData.dplastupdate)
					p << "<span style=\"color:red;\">The Daily Prophet has an issue that you haven't yet read. <a href='?src=\ref[src];action=daily_prophet'>Click here</a> to view.</span>"
				if(VERSION != p.lastversion)
					p.lastversion = VERSION
					src<<"<b><span style=\"font-size:2;\">TWC had an update since you last logged in! A list of changes can be found <a href='http://wizardschronicles.com/?ver=[VERSION]'>here.</a></span></b>"


mob/Player/var/lastversion
var/rules = file("rules.html")

mob/BaseCamp
	base_save_allowed = 0
	Login()
		RemoveVerbs()
		return

	Stat()
		return

	proc/RemoveVerbs()
		for (var/my_verb in verbs)
			verbs -= my_verb

mob/BaseCamp/FirstTimePlayer
	proc/FirstTimePlayer()
		return 1

world
	mob = /mob/BaseCamp/ChoosingCharacter
/*var/HTML/HTML
var/HTMLres = list('logo_banner.png', 'logo.png', 'mainstyle.css')
mob/BaseCamp/ChoosingCharacter/Topic(href,href_list[])
	switch(href_list["action"])
		if("loginLoad")
			if(istype(src,/mob/BaseCamp/ChoosingCharacter))
				Choose_Character()
		if("loginNew")
			if(istype(src,/mob/BaseCamp/ChoosingCharacter))
				New_Character()

client/Topic(href,href_list[],hsrc)
	..()
	switch(href_list["action"])
		if("login")
			if(href_list["btnregister"])
				usr << output(HTMLOutput(usr,"register",href_list),"broLogin")
		if("register")
			if(href_list["btncancel"])
				usr << output(HTMLOutput(usr,"login",href_list),"broLogin")
				return
			if(length(href_list["emailaddress"]) < 6\
			|| length(href_list["emailaddress"]) > 60\
			|| !findtext(href_list["emailaddress"],"@"))
				href_list["error"] = "Invalid email address entered."
			else if(!cmptext(href_list["emailaddress"],href_list["emailaddressconfirm"]))
				href_list["error"] = "Email addresses don't match."

			else if(length(href_list["password"]) < 5\
			|| length(href_list["password"]) > 60)
				href_list["error"] = "Password must be between 5 and 60 characters in length."
			else if(!cmptext(href_list["password"],href_list["passwordconfirm"]))
				href_list["error"] = "Passwords don't match."
			if(href_list["error"])
				usr << output(HTMLOutput(usr,"register",href_list),"broLogin")
proc/HTMLOutput(mob/M,page,list/href_list)
	//for(var/res in HTMLres)
	//	M << browse_rsc(res)
	switch(page)
		if("login")
			return {"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="mainstyle.css" />
</head>
<body>
	<div id="centerwrapper">
		<div style="margin-left:auto;margin-right:auto;width: 700px;height: 300px">
			<div style="float: left;width:263px;">
				<img src="silver_logo.jpg" />
			</div>
			<div style="text-align:right;padding-top:40px;">
			<form action="byond://" method="get">
				<label for="emailaddress">Email Address:</label><input id="emailaddress" name="emailaddress" /><br />
				<label for="password">Password:</label><input id="password" name="password" type="password" /><br />
				<input id="remember" type="checkbox" /><label for="remember">Remember login email</label>
				<br />
				<input type="button" name="btnregister" value="Register" style="width:100px;margin-right:3px;" onclick="window.location='?action=login;btnregister=1'" /><input type="submit" value="Login" style="width:100px;" />
				<input type="hidden" name="action" value="login" />
				<br />
				[href_list ? "<span class=\"error\">[href_list["error"]]</span>":]
			</form>
			</div><div style="clear: both"></div>
		</div>
	</div>
</body>
</html>"}
		if("register")
			return {"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="mainstyle.css" />
</head>
<body>
	<div id="centerwrapper">
		<div style="margin-left:auto;margin-right:auto;width: 700px;height: 300px">
			<div style="float: left;width:263px;">
				<img src="silver_logo.jpg" />
			</div>
			<div style="text-align:right;padding-top:30px;">
			<form action="byond://" method="get">
				<label for="emailaddress">Email Address:</label><input id="emailaddress" name="emailaddress" /><br />
				<label for="emailaddressconfirm">Confirm Email Address:</label><input id="emailaddressconfirm" name="emailaddressconfirm" /><br />
				<br />
				<label for="password">Password:</label><input id="password" name="password" type="password" /><br />
				<label for="passwordconfirm">Confirm Password:</label><input id="passwordconfirm" name="passwordconfirm" type="password" /><br />
				<br />
				<input type="button" name="btncancel" value="Cancel" style="width:100px;margin-right:3px;" onclick="window.location='?action=register;btncancel=1'" /><input type="submit" value="Register" style="width:100px;" />
				<input type="hidden" name="action" value="register" />
				<br />
				[href_list ? "<span class=\"error\">[href_list["error"]]</span>":]
			</form>
			</div><div style="clear: both"></div>
		</div>
	</div>
</body>
</html>"}
	return {"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="http://wizardschronicles.com/login/mainstyle.css" />
</head>
<body onresize="hideDiv()">
		<div id="banner">
			<img src="http://wizardschronicles.com/login/logo_banner.png" />
		</div>
		<div id="logo">
			<img src="http://wizardschronicles.com/login/logo.png" />
		</div>
		<div id="main">
				<ul class="centered-ul">
					<li class="horizontal-li"><a href="?src=\ref[M];action=loginNew">New</a></li>
					<li class="horizontal-li"> - </li>
					<li class="horizontal-li"><a href="?src=\ref[M];action=loginLoad">Load</li>
				</ul>
		</div>

	<script language=javascript type='text/javascript'>
		var swap = false;
		hideDiv();
		function hideDiv()
		{
			if(document.documentElement.offsetHeight < 480 && !swap)
			{
				swapNodes(document.getElementById('logo'), document.getElementById('main'));
				swap = true;
			}
			else if(document.documentElement.offsetHeight >= 480 && swap)
			{
 				swapNodes(document.getElementById('logo'), document.getElementById('main'));
				swap = false;
			}
		}

		function swapNodes(node1, node2)
		{
    		node2_copy = node2.cloneNode(true);
    		node1.parentNode.insertBefore(node2_copy, node1);
    		node2.parentNode.insertBefore(node1, node2);
    		node2.parentNode.replaceChild(node2, node2_copy);
		}
	</script>
</body>
</html>"}
*/
client/var/tmp/interface/tmpInterface

hudobj
	login
		anchor_x = "CENTER"
		anchor_y = "CENTER"

		mouse_opacity = 2

		icon = 'Login Stone.dmi'
		icon_state = "moss"

		appearance_flags = PIXEL_SCALE

		MouseEntered()
			transform *= 1.25
		MouseExited()
			transform = null


		Load
			maptext = "<b><span style=\"font-size:14px;color:#34d\">Load</span></b>"
			maptext_width = 64
			maptext_x = 9
			maptext_y = 4

			screen_x = 64

			Click()
				if(istype(usr,/mob/BaseCamp/ChoosingCharacter))
					usr:Choose_Character()

		New
			maptext = "<b><span style=\"font-size:14px;color:#34d\">New</span></b>"
			maptext_width = 64
			maptext_x = 10
			maptext_y = 4

			screen_x = -94

			Click()
				if(istype(usr,/mob/BaseCamp/ChoosingCharacter))
					usr:New_Character()

obj/loginCamera
	mouse_opacity = 0
	invisibility = 10
	glide_size = 8

	New()
		..()
		tag = "loginCamera"
		wander()

	proc/wander()
		set waitfor = 0
		var/turf/target
		while(src)
			if(!target || loc == target)
				target = locate(rand(50,70), rand(25,85), z)

			var/turf/t = get_step_towards(loc, target)
			if(t)
				loc = t
			else
				target = null
			sleep(4)


mob/tmpmob
mob/BaseCamp/ChoosingCharacter
	sight = SEE_THRU
	Login()
		client.initMapBrowser()
		new /hudobj/login/New(null, client, null, 1)
		new /hudobj/login/Load(null, client, null, 1)

		client.tmpInterface = new (client)
		client.onResize(60, 31, 0, 0, 1)

		var/obj/o = locate("loginCamera")
		client.eye = o
		client.perspective = EYE_PERSPECTIVE

	//	usr << output(HTMLOutput(src),"broLogin")
		/*var/first_initial = copytext(ckey, 1, 2)
		if(fexists("players/[first_initial]/[ckey].sav"))
			var/mob/tmpmob/A
			var/mob/tmpmob/M = new()
			var/savefile/S = new("players/[first_initial]/[ckey].sav")
			S.cd = "/players/[ckey]/mobs/"
			var/firstentry
			for (var/entry in S)
				S["[entry]/mob"] >> M
				//M = S["[entry]/mob"]The nurse orbs out
				break
{'fraction_non_alphanumeric': 0.16746918093125268, 'fraction_numerical': 0.012705775581717801, 'mean_word_length': 3.3438458169075775, 'pattern_counts': {'":': 4, '<': 443, '<?xml version=': 0, '>': 367, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7102978', 'n_tokens_mistral': 18270, 'n_tokens_neox': 14786, 'n_words': 2714}