Reads a face from a disk file Parameters: ifile - file to read from fp - face to read version - the version number of the file being read Returns: 1 if read ok, else 0
| 1959 | // version - the version number of the file being read |
| 1960 | // Returns: 1 if read ok, else 0 |
| 1961 | int ReadFace(CFILE *ifile, face *fp, int version) { |
| 1962 | int nverts, i; |
| 1963 | |
| 1964 | // Get number of verts |
| 1965 | nverts = cf_ReadByte(ifile); |
| 1966 | |
| 1967 | // Initialize & alloc memory |
| 1968 | InitRoomFace(fp, nverts); |
| 1969 | |
| 1970 | // Read vertices |
| 1971 | for (i = 0; i < fp->num_verts; i++) |
| 1972 | fp->face_verts[i] = cf_ReadShort(ifile); |
| 1973 | |
| 1974 | // Read uvls, and adjust alpha settings |
| 1975 | int alphaed = 0; |
| 1976 | |
| 1977 | for (i = 0; i < fp->num_verts; i++) { |
| 1978 | fp->face_uvls[i].u = cf_ReadFloat(ifile); |
| 1979 | fp->face_uvls[i].v = cf_ReadFloat(ifile); |
| 1980 | |
| 1981 | if (version < 56) { |
| 1982 | // Read old lrgb stuff |
| 1983 | cf_ReadFloat(ifile); |
| 1984 | cf_ReadFloat(ifile); |
| 1985 | cf_ReadFloat(ifile); |
| 1986 | cf_ReadFloat(ifile); |
| 1987 | } |
| 1988 | |
| 1989 | if (version >= 21) { |
| 1990 | if (version < 61) |
| 1991 | fp->face_uvls[i].alpha = Float_to_ubyte(cf_ReadFloat(ifile)); |
| 1992 | else |
| 1993 | fp->face_uvls[i].alpha = cf_ReadByte(ifile); |
| 1994 | } else |
| 1995 | fp->face_uvls[i].alpha = 1.0; |
| 1996 | |
| 1997 | if (fp->face_uvls[i].alpha != 255) |
| 1998 | alphaed = 1; |
| 1999 | } |
| 2000 | |
| 2001 | // Read flags |
| 2002 | if (version < 27) |
| 2003 | fp->flags = cf_ReadByte(ifile); |
| 2004 | else |
| 2005 | fp->flags = cf_ReadShort(ifile); |
| 2006 | |
| 2007 | // Kill old portal trigger flag |
| 2008 | if (version < 103) |
| 2009 | fp->flags &= ~OLD_FF_PORTAL_TRIG; |
| 2010 | |
| 2011 | // Set vertex alpha flag |
| 2012 | if (alphaed) |
| 2013 | fp->flags |= FF_VERTEX_ALPHA; |
| 2014 | else |
| 2015 | fp->flags &= ~FF_VERTEX_ALPHA; |
| 2016 | |
| 2017 | // Read the portal number |
| 2018 | if (version >= 23) |
no test coverage detected