bool replay_save(Replay *rpy, const char *name) { char *p = replay_getpath(name, !strendswith(name, REPLAY_EXTENSION)); char *sp = vfs_repr(p, true); log_info("Saving %s", sp); free(sp); SDL_RWops *file = vfs_open(p, VFS_MODE_WRITE); free(p); if(!file) { log_warn("VFS error: %s", vfs_get_error()); return false; } bool result = replay_write(rpy, file, REPLAY_STRUCT_VERSION_WRITE); SDL_RWclose(file); return result; }
int replay_save(Replay *rpy, char *name) { char *p = replay_getpath(name, !strendswith(name, REPLAY_EXTENSION)); printf("replay_save(): saving %s\n", p); FILE *fp = fopen(p, "w"); free(p); if(!fp) { printf("replay_save(): fopen() failed\n"); return False; } int result = replay_write(rpy, fp); fflush(fp); fclose(fp); return result; }
void putsock(const char *text, ...) { va_list arg_list; char buffer[MAXLEN]; int pos; if (!cManager.uplink || cManager.uplink->state == DISCONNECTED) return; buffer[0] = '\0'; va_start(arg_list, text); pos = vsnprintf(buffer, MAXLEN - 2, text, arg_list); va_end(arg_list); if (pos < 0 || pos > (MAXLEN - 2)) pos = MAXLEN - 2; buffer[pos] = 0; if (!replay_file) { log_replay(MAIN_LOG, true, buffer); buffer[pos++] = '\n'; buffer[pos] = 0; ioset_write(socket_io_fd, buffer, pos); } else { replay_write(buffer); } }