# sparrput

if arrsize('ARGS') < 6:
	'ERROR: sparrput called incorrectly. report to a maintainer'
end

!{'sparr  boy <<$ARGS[0]>> loc <<ARGS[1]>> ppt <<ARGS[2]>> know <<ARGS[3]>> vol <<ARGS[4]>> spread <<ARGS[5]>> age <<ARGS[6]>>'}
i = arrsize('$sparrnam')
s = ARGS[5]

!{Check for prev spatter by same guy}
i2 = 0
:sparrputloop
if i2 < i:
	if sparrloc[i2] = ARGS[1] and $sparrnam[i2] = $ARGS[0]:
		i = i2
		!{Use existing spread value if greater than provided}
		if s < sparrslc[i]: s = sparrslc[i]
	else
		i2 += 1
		jump 'sparrputloop'
	end
end

$sparrnam[i] = $ARGS[0]
sparrloc[i] = ARGS[1]
sparrppt[i] = ARGS[2]
if ARGS[3]:
	sparridt[i] = ARGS[3]
end
sparrvol[i] += ARGS[4]
sparrslc[i] = s

if ARGS[6] ! 0:
	sparrage[i] = ARGS[6]
else
	sparrage[i] = 0
end

RESULT = i

--- sparrput ---------------------------------

