Normally you don't use vertices when dealing with c_trace (or any other function), I assume in your case you simply grab the position (!!) of two vertices and use this, not the vertices themselves.
The function prototype for c_trace reads as follows:
c_trace(VECTOR* from, VECTOR* to, var mode)
You only need to have or calculate two positions. This could be done as follows - the code is untested, but it should give you the right idea:
function camera_follow(ENTITY* ent)
{
var camera_distance, camera_distance_max;
VECTOR camera_target;
camera_distance_max = vec_length(vector(-200,-35,45));
camera_distance = camera_distance_max;
while(1)
{
// calculate camera target
vec_set(camera_target.x,vector(-200,-35,45)); //camera position relative to the player
vec_rotate(camera_target.x,ent.pan); // rotate the camera position with the player
vec_add(camera_target.x,ent.x); // add player position
camera_distance += (camera_distance_max-camera_distance)*0.2*time_step; // for a smoother wall alignment
// check for walls
set(ent,PASSABLE);
result = c_trace(ent.x,camera_target,IGNORE_PASSABLE);
reset(ent,PASSABLE);
if(trace_hit) camera_distance = minv(camera_distance,result);
// set camera position
vec_lerp(camera.x,ent.x,camera_target.x,camera_distance/camera_distance_max);
vec_set(camera.pan,vector(ent.pan,-5,0)); // look in player direction, slighty down
wait(1);
}
}
EDIT: If the camera still looks through walls, try to replace
if(trace_hit) camera_distance = minv(camera_distance,result);
with
if(trace_hit) camera_distance = minv(camera_distance,result-32);
or any other negative value.