/* Prints a fatal error message and adds file and line number, then terminates. */ int ErrorAt(const char *filename, long line, unsigned long offset, const char *format, ...) { va_list marker; POVMSObject msg; char localvsbuffer[1024]; sprintf(localvsbuffer, "%s Error: ", Stage_Names[STAGE_PARSING].stage_name); va_start(marker, format); vsnprintf(localvsbuffer + strlen(localvsbuffer), 1023 - strlen(localvsbuffer), format, marker); va_end(marker); CleanupString(localvsbuffer); (void)POVMSObject_New(&msg, kPOVObjectClass_FileLoc); (void)POVMSUtil_SetString(&msg, kPOVAttrib_FileName, filename); (void)POVMSUtil_SetInt(&msg, kPOVAttrib_Line, line); (void)POVMSUtil_SetInt(&msg, kPOVAttrib_Column, 0); (void)POVMSUtil_SetLong(&msg, kPOVAttrib_FilePosition, offset); (void)POVMSUtil_SetString(&msg, kPOVAttrib_EnglishText, localvsbuffer); (void)POVMSUtil_SetInt(&msg, kPOVAttrib_Error, 0); (void)POVMSMsg_SetupMessage(&msg, kPOVMsgClass_RenderOutput, kPOVMsgIdent_FatalError); (void)POVMSMsg_SetDestinationAddress(&msg, FRONTEND_ADDRESS); (void)POVMS_Send(POVMS_Render_Context, &msg, NULL, kPOVMSSendMode_NoReply); Terminate_Tokenizer(); /* Closes scene file */ POV_SHELLOUT(FATAL_SHL); povray_exit(1); return 0; }
/* Prints a fatal error message and adds file and line number if parsing, then terminates. */ int Error(const char *format,...) { va_list marker; POVMSObject msg; char localvsbuffer[1024]; sprintf(localvsbuffer, "%s Error: ", Stage_Names[Stage].stage_name); va_start(marker, format); vsnprintf(localvsbuffer + strlen(localvsbuffer), 1023 - strlen(localvsbuffer), format, marker); va_end(marker); CleanupString(localvsbuffer); if((Stage == STAGE_PARSING) || (Stage == STAGE_INCLUDE_ERR) || (Stage == STAGE_FOUND_INSTEAD)) { (void)POVMSObject_New(&msg, kPOVObjectClass_FileLoc); Where_Error(&msg); (void)POVMSUtil_SetString(&msg, kPOVAttrib_EnglishText, localvsbuffer); (void)POVMSUtil_SetInt(&msg, kPOVAttrib_Error, 0); (void)POVMSMsg_SetupMessage(&msg, kPOVMsgClass_RenderOutput, kPOVMsgIdent_FatalError); (void)POVMSMsg_SetDestinationAddress(&msg, FRONTEND_ADDRESS); (void)POVMS_Send(POVMS_Render_Context, &msg, NULL, kPOVMSSendMode_NoReply); } else { (void)POVMSObject_New(&msg, kPOVObjectClass_FileLoc); (void)POVMSUtil_SetString(&msg, kPOVAttrib_EnglishText, localvsbuffer); (void)POVMSUtil_SetInt(&msg, kPOVAttrib_Error, 0); (void)POVMSMsg_SetupMessage(&msg, kPOVMsgClass_RenderOutput, kPOVMsgIdent_FatalError); (void)POVMSMsg_SetDestinationAddress(&msg, FRONTEND_ADDRESS); (void)POVMS_Send(POVMS_Render_Context, &msg, NULL, kPOVMSSendMode_NoReply); } /* This could be just an "if" but we may add special messages later */ if(Stage == STAGE_INCLUDE_ERR) { Warning(0, "Check that the file is in a directory specifed with a +L switch\n" "or 'Library_Path=' .INI item. Standard include files are in the\n" "include directory or folder. Please read your documentation carefully."); } Terminate_Tokenizer(); /* Closes scene file */ POV_SHELLOUT(FATAL_SHL); povray_exit(1); return 0; }
void FrameLoop() { int Diff_Frame; DBL Diff_Clock; SHELLRET Pre_Scene_Result, Frame_Result; Diff_Clock = opts.FrameSeq.FinalClock - opts.FrameSeq.InitialClock; if(opts.Options & CYCLIC_ANIMATION) Diff_Frame = opts.FrameSeq.FinalFrame - opts.FrameSeq.InitialFrame + 1; else Diff_Frame = opts.FrameSeq.FinalFrame - opts.FrameSeq.InitialFrame; Clock_Delta = ((Diff_Frame == 0) ? 0 : Diff_Clock/Diff_Frame); // Execute the first shell-out command Pre_Scene_Result = (POV_SHELLOUT_CAST)POV_SHELLOUT(PRE_SCENE_SHL); // Loop over each frame if(Pre_Scene_Result != ALL_SKIP_RET) { if(Pre_Scene_Result != SKIP_ONCE_RET) { for(opts.FrameSeq.FrameNumber = opts.FrameSeq.InitialFrame, opts.FrameSeq.Clock_Value = opts.FrameSeq.InitialClock; opts.FrameSeq.FrameNumber <= opts.FrameSeq.FinalFrame; // ISO/IEC 14882:1998(E) section 5.18 Comma operator [expr.comma] (page 90) says // that comma expressions are evaluated left-to-right, and according to section // 6.5.3 The for statement [stmt.for] (page 97) the following is an expression. // I just hope all compilers really know about the standard... [trf] opts.FrameSeq.FrameNumber++, opts.FrameSeq.Clock_Value = opts.FrameSeq.InitialClock + (Clock_Delta * (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame))) { if(opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME) { START_TIME Send_Progress("Processing Frame", PROGRESS_PROCESSING_FRAME); } setup_output_file_name(); // Execute a shell-out command before tracing Frame_Result = (POV_SHELLOUT_CAST)POV_SHELLOUT(PRE_FRAME_SHL); if(Frame_Result == ALL_SKIP_RET) break; if(Frame_Result != SKIP_ONCE_RET) { FrameRender(); // Execute a shell-out command after tracing Frame_Result = (POV_SHELLOUT_CAST)POV_SHELLOUT(POST_FRAME_SHL); if((Frame_Result == SKIP_ONCE_RET) || (Frame_Result == ALL_SKIP_RET)) break; } if(opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME) Send_FrameStatistics(); Do_Cooperate(1); } // Print total stats ... if(opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME) { opts.FrameSeq.FrameNumber--; Send_RenderStatistics(true); opts.FrameSeq.FrameNumber++; } } // Execute the final shell-out command POV_SHELLOUT(POST_SCENE_SHL); } }