I've been messing with it a lot. The normals look fine. I just can't figure out what's causing it.

I calculate the normals for every triangle, then use those normals to calculate the normals for each vertex. Here is the function that calculates the vertex normals. Can someone please look over it for me?

Code:

void Map::calcVertexNorms()
{
float l;
pos normal;
normal.x = normal.y = normal.z = 0.0f;
int pitch = numTrisW*2;
for (int i=0; i < pitch*numTrisH; i+=2)
{
normal.x += mapTris[i].norm.x;
normal.y += mapTris[i].norm.y;
normal.z += mapTris[i].norm.z;
normal.x += mapTris[i+1].norm.x;
normal.y += mapTris[i+1].norm.y;
normal.z += mapTris[i+1].norm.z;
if (i - pitch > 0)
{
normal.x += mapTris[i-pitch].norm.x;
normal.y += mapTris[i-pitch].norm.y;
normal.z += mapTris[i-pitch].norm.z;
}
if (i - pitch > 0 && i % pitch != 0 && i % pitch != 1)
{
normal.x += mapTris[i-pitch-1].norm.x;
normal.y += mapTris[i-pitch-1].norm.y;
normal.z += mapTris[i-pitch-1].norm.z;
normal.x += mapTris[i-pitch-2].norm.x;
normal.y += mapTris[i-pitch-2].norm.y;
normal.z += mapTris[i-pitch-2].norm.z;
}
if (i % pitch != 0)
{
normal.x += mapTris[i-1].norm.x;
normal.y += mapTris[i-1].norm.y;
normal.z += mapTris[i-1].norm.z;
}
l = sqrtf((normal.x * normal.x) + (normal.y * normal.y) + (normal.z * normal.z));
normal.x /= l;
normal.y /= l;
normal.z /= l;
mapTris[i].verts[0].norm = normal;
mapTris[i+1].verts[0].norm = normal;
if (i - pitch > 0)
{
mapTris[i-pitch].verts[1].norm = normal;
}
if (i - pitch > 0 && i % pitch != 0 && i % pitch != 1)
{
mapTris[i-pitch-1].verts[1].norm = normal;
mapTris[i-pitch-2].verts[2].norm = normal;
}
if (i % pitch != 0)
{
mapTris[i-1].verts[2].norm = normal;
}
}
}

If you need any clarifications let me know, because I made this on my own with out looking at any other terrain engines.