Olympiad number theory problem I found this problem in previous problems of the olympiads of my country

If  $t^2+n^2=r^2$, where $t$ has $3$ positive divisors, $n$ has $30$ positive divisors and $t,n,r$ are natural numbers, find the sum of all the possible values of $t$

I did gave it a try but only solved it partially, and I really doubt this is the best way to do it.
My progress:
First, $t$ must be of the form $p^2$ where $p$ is prime
Then,  we use pythagorean triplets
Case 1:
$$t=p^2=2ab$$
$$n=a^2-b^2$$
Therfore, $p$ must be $2$, therefore $a=2, b=1$, but  this does not satisfy $n$ having $30$ divisors.
Case 2:
$$t=p^2=a^2-b^2=(a-b)(a+b)$$
$$n=2ab$$
Since $p$ is prime, we get $a=b+1$, therefore
$$p^2=2b+1$$
$$n=2(b+1)b$$
If $n$ has $30$ divisors, it must be of one of the forms
$$q^{29},r^{14}q,r^{9}q^2,r^4q^5,r^4q^2s$$
Where $r,q,s$ are different primes
Since $p$ is odd, $p^2=8k+1=2b+1$, $b=4k$ for some integer $k$
Case 2.1
$$8k(4k+1)=r^{29}\implies 4k(4k+1)=2^{28}$$
That is clearly impossible
Case 2.2
$$8k(8k+1)=r^{14}q\implies r=2$$
$$4k(4k+1)=2^{13}q$$
$$\implies 4k=2^{13} \implies q=4k+1=2^{13}+1=3×2731$$
Case 2.3
$$8k(4k+1)=r^9q^2\implies r=2$$
$$8k(4k+1)=2^9q^2$$
$$4k(4k+1)=2^8q^2$$
$$\implies 4k=2^8\implies q^2=4k+1=256+1=257$$
Case 2.4
$$8k(4k+1)=r^4q^5$$
Case 2.4.1($r=2$)
$$4k(4k+1)=2^3q^5$$
$$\implies 4k=8\implies q^5=4k+1=8+1=9$$
Case 2.4.2($q=2$)
$$4k(4k+1)=r^42^4$$
$$\implies 4k=16\implies r^4=4k+1=16+1=17$$
Case 2.5
$$8k(4k+1)=r^4q^2s\implies r=2$$
$$8k(4k+1)=16q^2s$$
$$8k(8k+2)=32q^2s$$
$$(p-1)(p+1)=32q^2s$$
$$p^2-1=32q^2s$$
Where all $p,q,s$ are odd primes
The question now is: how do I proceed from here? Was there an easier way to solve this?

Let us start as you did. I will assume that $t$, $n$ and $r$ are coprime. Then $t=a^2-b^2$ and $n=2ab$. See the answer of André Nicolas for the case when $t$, $n$ and $r$ are not coprime.
We get that 
\begin{align*}
p^2 &= 2b+1,\\
n &= 2(b+1)b.
\end{align*}
Therefore,
$$n = \frac{p^4-1}{2} = (p-1) \times (p+1) \times \frac{p^2+1}{2}.$$
Note that every prime number $a \neq 2$ divides at most one of the terms $(p-1)$, $(p+1)$, and $\frac{p^2+1}{2}$. 
If neither of these terms is a power of 2, then $n$ has at least $4$ prime factors: 2, a prime divisor of $p-1$ (other than 2), a prime divisor of $p+1$ (other than 2), a prime divisor of $\frac{p^2+1}{2}$. This is impossible since $n$ has 30 divisors.
We conclude that one of the numbers $p-1$, $p+1$, $\frac{p^2+1}{2}$ is a power of 2. Note that $\frac{p^2+1}{2}$ is odd. Thus either $p-1$ or $p+1$ is a power of 2. 
Note that then $n$ has 3 prime factors: 2, a prime divisor of either $p-1$ or $p+1$ (other than 2), a prime divisor of $\frac{p^2+1}{2}$. So it must be the case that $n=r^4 q^2 s$. Since $n = (p^4-1)/2$ is divisible by 8, we have that $r=2$. 
Consider two cases


*

*$p-1$ is a power of 2. Observe that $p\neq 3$. Then $p+1$ is divisible by 2 but not by 4. We have $p - 1 = 8$ and $p=9$. Then $n=3280$. But $3280$ has 20 factors.

*$p+1$ is a power of $2$. Then $p-1$ is divisible by 2 but not by 4. We have $p + 1 = 8$ and $p=7$. Then $n = 1200$. We check that 1200 has 30 factors.


Answer: $t=49$, $n =1200$ and $r=1201$.
