void CBodyDlg::SetBodyTypeFromFilename () { ApjBodyFormat Fmt; Fmt = AProject_GetBodyFormatFromFilename (m_BodyName); if (Fmt != ApjBody_Invalid) { m_BodyFormat = IndexFromBodyFormat (Fmt); } }
static geBoolean AProject_LoadBodyInfo (AProject *pProject, geVFile *FS) { for (;;) { char Buffer[1024]; char *c; if (AProject_GetNonBlankLine (FS, Buffer, sizeof (Buffer)) != READ_SUCCESS) { geErrorLog_AddString (GE_ERR_FILEIO_READ, "Loading Body info",NULL); return GE_FALSE; } if (_strnicmp (Buffer, BodyFilename_Key, strlen (BodyFilename_Key)) == 0) { c = &Buffer[strlen (BodyFilename_Key)]; AProject_SetString (&pProject->Body.Filename, c); // if we haven't loaded a format yet, try to get it from the filename // this will be overridden by a format if it's there... if (pProject->Body.Fmt == ApjBody_Invalid) { pProject->Body.Fmt = AProject_GetBodyFormatFromFilename (pProject->Body.Filename); } } else if (_strnicmp (Buffer, BodyFormat_Key, strlen (BodyFormat_Key)) == 0) { c = &Buffer[strlen (BodyFormat_Key)]; // Determine body file format if (*c != '\0') { switch (*(c+1)) { case '1' : pProject->Body.Fmt = ApjBody_Max; break; case '2' : pProject->Body.Fmt = ApjBody_Nfo; break; case '3' : pProject->Body.Fmt = ApjBody_Bdy; break; case '4' : pProject->Body.Fmt = ApjBody_Act; break; default : pProject->Body.Fmt = ApjBody_Invalid; break; } } else { pProject->Body.Fmt = ApjBody_Invalid; } if (pProject->Body.Fmt == ApjBody_Invalid) { geErrorLog_AddString (GE_ERR_FILEIO_FORMAT, "Unknown body file format",NULL); return GE_FALSE; } } else if (_strnicmp (Buffer, EndBody_Key, strlen (EndBody_Key)) == 0) { if (pProject->Body.Fmt == ApjBody_Invalid) { geErrorLog_AddString (GE_ERR_FILEIO_FORMAT, "Unknown body file format",NULL); return GE_FALSE; } return GE_TRUE; } else { // bad entry geErrorLog_AddString (GE_ERR_FILEIO_FORMAT, "Bad Body section entry",NULL); return GE_FALSE; } } }