# saveupdater


if VersionCheck < 504:
	gs 'npcstatic'
	pcs_dob = birthyear * 10000
	pcs_dob += birthmonth * 100
	pcs_dob += birthday
	pcs_horny = horny
	pcs_stren = stren
	pcs_agil  = agil
	pcs_vital = vital
	pcs_intel = intel
	pcs_haircol = hcol
	Astat_rel[28] = father
	Astat_rel[29] = mother
	Astat_rel[33] = sister
	Astat_rel[34] = brother
	pcs_grades = Suspeh
	pcs_tan = tan
	pcs_vball = volleyboll
	pcs_hairlng = hairlength
	pcs_haircol = hcol
	Astat_nerd[pc] = nerdism
	pcs_dom = dom
	$Astat_firstname[npctemp] = $name
	$Astat_nickname[npctemp] = $nickname
	$Astat_lastname[npctemp] = $surname
	$Astat_usedname[npctemp] = $nickname
	VersionCheck = 5030
	Astat_Qstlvl[33] = sisboyQW
	Astat_Qstlvl[34] = brotherQW
	Astat_Qstlvl[29] = motherQW
	Astat_Qstlvl[89] = barmenshameet
	Astat_rel[89] = JenyaLC
	LCEugenefirst = JenyaLCfirst
	killvar 'sisboyQW'
	killvar 'brotherQW'
	killvar 'motherQW'
	killvar 'barmenshameet'
	killvar 'JenyaLC'
	killvar 'JenyaLCfirst'
	killvar 'horny'
	killvar 'stren'
	killvar 'agil'
	killvar 'vital'
	killvar 'intel'
	killvar 'hcol'
	killvar 'father'
	killvar 'mother'
	killvar 'sister'
	killvar 'brother'
	killvar 'Suspeh'
	killvar 'tan'
	killvar 'volleyboll'
	killvar 'hairlength'
	killvar 'hcol'
	killvar 'nerdism'
	killvar 'dom'
	killvar '$name'
	killvar '$nickname'
	killvar '$surname'
	killvar '$boy'
	$boy = 'D0'

	!!The following part update the cum related arrays from an old savegame to the new MGX format.
	cycletemp = 0
	:cumarrupd
	if cycletemp < arrsize('$cumarrnam'):
		tempnpcid = arrpos('$Astat_usedname', $cumarrnam[cycletemp])
		if tempnpcid > 0:
			MSG '<br><b><font color="teal">DEBUG: Legacy name in save updated from <<$cumarrnam[cycletemp]>> to A<<tempnpcid>></font></b>'
			$cumarrnam[cycletemp] = 'A<<tempnpcid>>'
		elseif cumarrkno[cycletemp] > 0:
			MSG '<br><b><font color="red">WARNING: Unable to upgrade correctly cum entry <<cycletemp>> with name <<$cumarrnam[cycletemp]>></font></b>'
			gs 'npcgeneratec', 0, $cumarrnam[cycletemp], rand(18,60)
			$cumarrnam[cycletemp] = $npclastgenerated
		else
			gs 'npcgeneratec', 0, $cumarrnam[cycletemp], rand(18,60)
			$cumarrnam[cycletemp] = $npclastgenerated
		end
		cycletemp += 1
		jump 'cumarrupd'
	end
	cycletemp = 0
	:sparrupd
	if cycletemp < arrsize('$sparrnam'):
		tempnpcid = arrpos('$Astat_usedname', $sparrnam[cycletemp])
		if tempnpcid > 0:
			MSG '<br><b><font color="teal">DEBUG: Legacy name in save updated from <<$sparrnam[cycletemp]>> to A<<tempnpcid>></font></b>'
			$sparrnam[cycletemp] = 'A<<tempnpcid>>'
		elseif sparrkno[cycletemp] > 0:
			MSG '<br><b><font color="red">WARNING: Unable to upgrade correctly spatter entry <<cycletemp>> with name <<$sparrnam[cycletemp]>></font></b>'
			gs 'npcgeneratec', 0, $sparrnam[cycletemp], rand(18,60)
			$sparrnam[cycletemp] = $npclastgenerated
		else
			gs 'npcgeneratec', 0, $sparrnam[cycletemp], rand(18,60)
			$sparrnam[cycletemp] = $npclastgenerated
		end
		cycletemp +=1
		jump 'sparrupd'
	end
	cycletemp = 0
	:cumcbcupd
	if cycletemp < arrsize('$ChildFath'):
		tempnpcid = arrpos('$Astat_usedname', $ChildFath[cycletemp])
		if tempnpcid > 0:
			MSG '<br><b><font color="teal">DEBUG: Legacy name in save updated from <<$ChildFath[cycletemp]>> to A<<tempnpcid>></font></b>'
			$ChildFath[cycletemp] = 'A<<tempnpcid>>'
		else
			MSG '<br><b><font color="red">WARNING: Unable to upgrade correctly father entry <<cycletemp>> with name <<$ChildFath[cycletemp]>></font></b>'
			gs 'npcgeneratec', 0, $ChildFath[cycletemp], rand(18,60)
			$ChildFath[cycletemp] = $npclastgenerated
		end
		tempnpcid = arrpos('$Astat_usedname', $ChildThFath[cycletemp])
		if tempnpcid > 0:
			MSG '<br><b><font color="teal">DEBUG: Legacy name in save updated from <<$ChildThFath[cycletemp]>> to A<<tempnpcid>></font></b>'
			$ChildThFath[cycletemp] = 'A<<tempnpcid>>'
		else
			MSG '<br><b><font color="red">WARNING: Unable to upgrade correctly tought father entry <<cycletemp>> with name <<$ChildThFath[cycletemp]>></font></b>'
			$ChildThFath[cycletemp] = 'unknown'
		end
		cycletemp +=1
		jump 'cumcbcupd'
	end
	cycletemp = 0
	:wombpotupd
	if cycletemp < arrsize('$wombpotfath'):
		tempnpcid = arrpos('$Astat_usedname', $wombpotfath[cycletemp])
		if tempnpcid > 0:
			MSG '<br><b><font color="teal">DEBUG: Legacy name in save updated from <<$wombpotfath[cycletemp]>> to A<<tempnpcid>></font></b>'
			$wombpotfath[cycletemp] = 'A<<tempnpcid>>'
		elseif $wombpotfath[cycletemp] = 'Unknown':
			$wombpotfath[cycletemp] = 'unknown'
		else
			MSG '<br><b><font color="red">WARNING: Unable to upgrade correctly father entry <<cycletemp>> with name <<$wombpotfath[cycletemp]>></font></b>'
			gs 'npcgeneratec', 0, $wombpotfath[cycletemp], rand(18,60)
			$wombpotfath[cycletemp] = $npclastgenerated
		end
		cycletemp +=1
		jump 'wombpotupd'
	end
	cycletemp = 0
	:cumfthupd
		if cycletemp < arrsize('$cumfthname'):
		tempnpcid = arrpos('$Astat_usedname', $cumfthname[cycletemp])
		if tempnpcid > 0:
			MSG '<br><b><font color="teal">DEBUG: Legacy name in save updated from <<$cumfthname[cycletemp]>> to A<<tempnpcid>></font></b>'
			$cumfthname[cycletemp] = 'A<<tempnpcid>>'
		else
			MSG '<br><b><font color="red">WARNING: Unable to upgrade correctly father entry <<cycletemp>> with name <<$cumfthname[cycletemp]>></font></b>'
			gs 'npcgeneratec', 0, $cumfthname[cycletemp], rand(18,60)
			$cumfthname[cycletemp] = $npclastgenerated
		end
		cycletemp +=1
		jump 'cumfthupd'
	end
end


--- saveupdater ---------------------------------

