| 1156 | uint8_t DemoLastOpcode = 0; |
| 1157 | |
| 1158 | void DemoFrame() { |
| 1159 | uint8_t opcode; |
| 1160 | if (Demo_flags != DF_PLAYBACK) |
| 1161 | return; |
| 1162 | if (!Demo_first_frame) { |
| 1163 | Demo_frame_ofs = 0; |
| 1164 | |
| 1165 | if (Demo_make_movie) { |
| 1166 | DoScreenshot(); |
| 1167 | } |
| 1168 | // This code slows down demo playback |
| 1169 | if (!Demo_play_fast) { |
| 1170 | |
| 1171 | float tdelta = timer_GetTime(); |
| 1172 | // if(Gametime<Demo_next_frame) |
| 1173 | //{ |
| 1174 | // mprintf(0,"!%.3f!",Demo_next_frame-Gametime); |
| 1175 | //} |
| 1176 | |
| 1177 | while ((Gametime + Demo_frame_ofs) < Demo_next_frame) { |
| 1178 | Demo_frame_ofs = timer_GetTime() - tdelta; |
| 1179 | } |
| 1180 | } |
| 1181 | } else { |
| 1182 | // mprintf(0,"This is the first frame in the demo playback!(%f)\n",Demo_next_frame); |
| 1183 | Gametime = Demo_next_frame; |
| 1184 | Demo_frame_time = 0; |
| 1185 | Demo_first_frame = false; |
| 1186 | } |
| 1187 | int exit_loop = 0; |
| 1188 | do { |
| 1189 | // Read one opcode at a time, and dispatch the proper function to read the rest of the data |
| 1190 | // Keep going until we hit a new frame |
| 1191 | try { |
| 1192 | opcode = cf_ReadByte(Demo_cfp); |
| 1193 | // mprintf(0,"Demo ocode: %d\n",opcode); |
| 1194 | } catch (...) { |
| 1195 | // End of file, so we're done playing the demo |
| 1196 | mprintf(0, "End of demo file!"); |
| 1197 | strcpy(Old_demo_fname, Demo_fname); |
| 1198 | DemoAbort(); |
| 1199 | // Do some cool stuff here, like end of demo stats or exit to the main menu |
| 1200 | if (Demo_looping) { |
| 1201 | Game_interface_mode = GAME_DEMO_LOOP; |
| 1202 | strcpy(Demo_fname, Old_demo_fname); |
| 1203 | } else { |
| 1204 | Game_interface_mode = GAME_POST_DEMO; |
| 1205 | } |
| 1206 | return; |
| 1207 | } |
| 1208 | switch (opcode) { |
| 1209 | case DT_NEW_FRAME: |
| 1210 | DemoReadNewFrame(); |
| 1211 | exit_loop = 1; |
| 1212 | break; |
| 1213 | case DT_OBJ: |
| 1214 | DemoReadObj(); |
| 1215 | break; |
no test coverage detected