I've noticed a number of functions in the code like this one from ai.c (2.06 branch)
00204 // see if a structure has the range to fire on a target 00205 BOOL aiStructHasRange(STRUCTURE *psStruct, BASE_OBJECT *psTarget) 00206 { 00207 WEAPON_STATS *psWStats; 00208 SDWORD xdiff,ydiff, longRange; 00209 00210 if (psStruct->asWeaps[0].nStat == 0) 00211 { 00212 // Can't attack without a weapon 00213 return FALSE; 00214 } 00215 00216 psWStats = psStruct->asWeaps[0].nStat + asWeaponStats; 00217 00218 xdiff = (SDWORD)psStruct->x - (SDWORD)psTarget->x; 00219 ydiff = (SDWORD)psStruct->y - (SDWORD)psTarget->y; 00220 longRange = proj_GetLongRange(psWStats,0); 00221 if (xdiff*xdiff + ydiff*ydiff < longRange*longRange) 00222 { 00223 // in range 00224 return TRUE; 00225 00226 } 00227 00228 return FALSE; 00229 } Where the function is passed pointers, but no work is done to the pointers. psStruct and psTarget are evaluated but unchanged. The only work is to *psWStats. Would it make sense in these cases to pass by value and avoid the pointers? _______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev