void Log_Write(char *s) { if (!Log_IsLogging()) return; VFS_WRITE(memlogfile, s, strlen(s)); // fprintf(logfile, "%s", s); }
METHODDEF(void) term_destination (j_compress_ptr cinfo) { my_destination_mgr *dest = (my_destination_mgr*) cinfo->dest; VFS_WRITE(dest->vfs, dest->buffer, OUTPUT_BUF_SIZE - dest->pub.free_in_buffer); dest->pub.next_output_byte = dest->buffer; dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; }
int make_topmost (int id) { // FILE *logfile; vfsfile_t *logfile; int i,j=0; mform_t tempform; char *temp; temp = va("Vr2_console.log"); memcpy(&tempform, &forms[id], sizeof(mform_t)); // logfile = fopen(va("%s/QMB.log", com_gamedir),"w"); logfile = FS_OpenVFS (temp, "wb", FS_GAME); for (i=id; i<MAX_FIELDS-1; i++) { if (forms[i+1].enabled) { if (logfile) { char *temp; // vfprintf(logfile, va("i: %d", i), ""); // vfprintf(logfile, va("copy: %d to %d", i+1, i), ""); temp = va("i: %d", i); VFS_WRITE(logfile, temp, strlen(temp)); temp = va("copy: %d to %d", i+1, i); VFS_WRITE(logfile, temp, strlen(temp)); } memcpy(&forms[i], &forms[i+1], sizeof(mform_t)); //forms[i] = forms[i+1]; } if ( (forms[i].enabled == false) && (j==0) ) j = i; } memcpy(&forms[j-1], &tempform, sizeof(mform_t)); form_focus = j-1; if (logfile) VFS_CLOSE(logfile); // fclose (logfile); form_focus = j-1; return j-1; }
METHODDEF(boolean) empty_output_buffer (j_compress_ptr cinfo) { my_destination_mgr *dest = (my_destination_mgr*) cinfo->dest; VFS_WRITE(dest->vfs, dest->buffer, OUTPUT_BUF_SIZE); dest->pub.next_output_byte = dest->buffer; dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; return TRUE; }
static void WRITEHEADER(void) { rankfileheader_t nh; nh.ident = RANKFILE_IDENT; nh.version = swaplong(RANKFILE_VERSION); nh.usedslots = swaplong(rankfileheader.usedslots); nh.leader = swaplong(rankfileheader.leader); nh.freeslot = swaplong(rankfileheader.freeslot); VFS_SEEK(rankfile, 0); VFS_WRITE(rankfile, &nh, sizeof(rankfileheader_t)); }
/* ============ Cvar_WriteVariables Writes lines containing "set variable value" for all variables with the archive flag set to true. ============ */ void Cvar_WriteVariables (vfsfile_t *f) { cvar_t *var; for (var = cvar_vars ; var ; var = var->next) if (var->archive) { char *temp; temp = va("%s \"%s\"\n", var->name, var->string); VFS_WRITE(f, temp, strlen(temp)); // fprintf (f, "%s \"%s\"\n", var->name, var->string); } }
void QTV_ForwardToServerEx (qbool skip_if_no_params, qbool use_first_argument) { char data[1024 + 100] = {0}, text[1024], *s; sizebuf_t buf; if ( cls.mvdplayback != QTV_PLAYBACK || !playbackfile /* || cls.qtv_ezquake_ext & QTV_EZQUAKE_EXT_CLC_STRINGCMD ???*/ ) return; if (skip_if_no_params) if (Cmd_Argc() < 2) return; // lowercase command for (s = Cmd_Argv(0); *s; s++) *s = (char) tolower(*s); if (cls.state == ca_disconnected) { Com_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0)); return; } if (strcmp(Cmd_Argv(0), "say_team") == 0 && !qtv_say_team.integer) { Com_Printf("Cannot send team messages. Use qtv_say_team 1 to override.\n"); return; } SZ_Init(&buf, (byte*) data, sizeof(data)); s = TP_ParseMacroString (Cmd_Args()); s = TP_ParseFunChars (s, true); text[0] = 0; // *cat is dangerous, ensure we empty buffer before use it if (use_first_argument) strlcat(text, Cmd_Argv(0), sizeof(text)); if (s[0]) { strlcat(text, " ", sizeof(text)); strlcat(text, s, sizeof(text)); } MSG_WriteShort (&buf, 2 + 1 + strlen(text) + 1); // short + byte + null terminated string MSG_WriteByte (&buf, qtv_clc_stringcmd); MSG_WriteString (&buf, text); VFS_WRITE(playbackfile, buf.data, buf.cursize); }
static void WRITE_PLAYERHEADER(int x, rankheader_t *oh) { rankheader_t nh; VFS_SEEK(rankfile, sizeof(rankfileheader_t)+((x-1)*sizeof(rankinfo_t))); nh.prev = swaplong(oh->prev); //score is held for convineance. nh.next = swaplong(oh->next); Q_strncpyz(nh.name, oh->name, sizeof(nh.name)); nh.pwd = swaplong(oh->pwd); nh.score = swapfloat(oh->score); VFS_WRITE(rankfile, &nh, sizeof(rankheader_t)); }
static void WRITE_PLAYERSTATS(int x, rankstats_t *os) { rankstats_t ns; int i; VFS_SEEK(rankfile, sizeof(rankfileheader_t)+sizeof(rankheader_t)+((x-1)*sizeof(rankinfo_t))); ns.kills = swaplong(os->kills); ns.deaths = swaplong(os->deaths); for (i = 0; i < NUM_RANK_SPAWN_PARMS; i++) ns.parm[i] = swapfloat(os->parm[i]); ns.timeonserver = swapfloat(os->timeonserver); ns.flags1 = (os->flags1); ns.trustlevel = (os->trustlevel); ns.pad2 = (os->pad2); ns.pad3 = (os->pad3); VFS_WRITE(rankfile, &ns, sizeof(rankstats_t)); }
/* =============== Host_Savegame_f =============== */ void Host_Savegame_f (void) { char name[256]; vfsfile_t *f; int i; char comment[SAVEGAME_COMMENT_LENGTH+1]; char *temp; if (cmd_source != src_command) return; if (!sv.active) { Con_Printf ("Not playing a local game.\n"); return; } if (cl.intermission) { Con_Printf ("Can't save in intermission.\n"); return; } if (svs.maxclients != 1) { Con_Printf ("Can't save multiplayer games.\n"); return; } if (Cmd_Argc() != 2) { Con_Printf ("save <savename> : save a game\n"); return; } if (strstr(Cmd_Argv(1), "..")) { Con_Printf ("Relative pathnames are not allowed.\n"); return; } for (i=0 ; i<svs.maxclients ; i++) { if (svs.clients[i].active && (svs.clients[i].edict->v.health <= 0) ) { Con_Printf ("Can't savegame with a dead player\n"); return; } } // sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1)); strcpy(name, Cmd_Argv(1)); COM_DefaultExtension (name, ".sav"); Con_Printf ("Saving game to %s...\n", name); // f = fopen (name, "w"); f = FS_OpenVFS(name, "wb", FS_GAMEONLY); if (!f) { Con_Printf ("ERROR: couldn't open.\n"); return; } // fprintf (f, "%i\n", SAVEGAME_VERSION); temp = va("%i\n", SAVEGAME_VERSION); VFS_WRITE(f, temp, strlen(temp)); Host_SavegameComment (comment); // fprintf (f, "%s\n", comment); temp = va("%s\n", comment); VFS_WRITE(f, temp, strlen(temp)); for (i=0 ; i<NUM_SPAWN_PARMS ; i++) { // fprintf (f, "%f\n", svs.clients->spawn_parms[i]); temp = va("%f\n", svs.clients->spawn_parms[i]); VFS_WRITE(f, temp, strlen(temp)); } // fprintf (f, "%d\n", current_skill); temp = va("%d\n", current_skill); VFS_WRITE(f, temp, strlen(temp)); // fprintf (f, "%s\n", sv.name); temp = va("%s\n", sv.name); VFS_WRITE(f, temp, strlen(temp)); // fprintf (f, "%f\n",sv.time); temp = va("%f\n", sv.time); VFS_WRITE(f, temp, strlen(temp)); // write the light styles for (i=0 ; i<MAX_LIGHTSTYLES ; i++) { if (sv.lightstyles[i][0]) temp = va("%s\n", sv.lightstyles[i]); // fprintf (f, "%s\n", sv.lightstyles[i]); else temp = va("m\n"); // fprintf (f,"m\n"); VFS_WRITE(f, temp, strlen(temp)); } ED_WriteGlobals (f); for (i=0 ; i<sv.num_edicts ; i++) { ED_Write (f, EDICT_NUM(i)); // fflush (f); } // fclose (f); VFS_CLOSE(f); Con_Printf ("done.\n"); }