/* <5c15> ../engine/cmd.c:1181 */ qboolean Cmd_ForwardToServerInternal(sizebuf_t *pBuf) { const char *cmd_name = Cmd_Argv(0); if (g_pcls.state <= ca_disconnected) { if (Q_stricmp(cmd_name, "setinfo")) { Con_Printf("Can't \"%s\", not connected\n", cmd_name); } return FALSE; } if (g_pcls.demoplayback || g_bIsDedicatedServer) { return FALSE; } char tempData[4096]; sizebuf_t tempBuf; tempBuf.buffername = __FUNCTION__ "::tempBuf"; tempBuf.data = (byte *)tempData; tempBuf.maxsize = 4096; tempBuf.cursize = 0; tempBuf.flags = SIZEBUF_ALLOW_OVERFLOW; MSG_WriteByte(&tempBuf, clc_stringcmd); if (Q_stricmp(cmd_name, "cmd")) { SZ_Print(&tempBuf, cmd_name); SZ_Print(&tempBuf, " "); } SZ_Print(&tempBuf, Cmd_Argc() <= 1 ? "\n" : Cmd_Args()); if (tempBuf.flags & SIZEBUF_OVERFLOWED) { return FALSE; } if (tempBuf.cursize + pBuf->cursize <= pBuf->maxsize) { SZ_Write(pBuf, tempBuf.data, tempBuf.cursize); return TRUE; } return FALSE; }
static void CL_SendConnectPacket_Q3(peer_t *p) { char tmp[128]; char data[2048]; byte msg_data[2048]; char biguserinfo[MAX_INFO_STRING + 100]; sizebuf_t msg; if (p->ps != ps_challenge) return; // add challenge to the temporary userinfo strlcpy (biguserinfo, p->userinfo, sizeof (biguserinfo)); snprintf(tmp, sizeof(tmp), "%d", p->challenge); Info_SetValueForKey(biguserinfo, "challenge", tmp, sizeof(biguserinfo)); // make string snprintf(data, sizeof(data), "\xff\xff\xff\xff" "connect \"%s\"", biguserinfo); // init msg SZ_InitEx(&msg, msg_data, sizeof(msg_data), true); SZ_Print(&msg, data); // god damn compress it Huff_EncryptPacket(&msg, 12); // ok, send it! NET_SendPacket(net_from_socket, msg.cursize, msg.data, &net_from); }
/* ============ Cvar_Set ============ */ void Cvar_Set (char *var_name, char *value) { cvar_t *var; var = Cvar_FindVar (var_name); if (!var) { // there is an error in C code if this happens Con_Printf ("Cvar_Set: variable %s not found\n", var_name); return; } #ifdef SERVERONLY if (var->info) { Info_SetValueForKey (svs.info, var_name, value, MAX_SERVERINFO_STRING); SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info); } #else if (var->info) { Info_SetValueForKey (cls.userinfo, var_name, value, MAX_INFO_STRING); if (cls.state >= ca_connected) { MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, va("setinfo \"%s\" \"%s\"\n", var_name, value)); } } #endif Z_Free (var->string); // free the old value string var->string = Z_Malloc (strlen(value)+1); strcpy (var->string, value); var->value = atof (var->string); }
void SCR_FinishCinematic(void) { /* tell the server to advance to the next map / cinematic */ MSG_WriteByte(&cls.netchan.message, clc_stringcmd); SZ_Print(&cls.netchan.message, va("nextserver %i\n", cl.servercount)); }
/* =============== CL_Say Handles both say and say_team =============== */ void CL_Say (qbool team) { extern cvar_t cl_fakename; char text[1024], sendtext[1024], *s; if (Cmd_Argc() < 2) { if (team) Com_Printf ("say_team <text>: send a team message\n"); else Com_Printf ("say <text>: send a chat message\n"); return; } if (cls.state == ca_disconnected) { Com_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0)); return; } MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, team ? "say_team " : "say "); s = TP_ParseMacroString (Cmd_Args()); strlcpy (text, TP_ParseFunChars (s, true), sizeof(text)); sendtext[0] = 0; if (team && !cl.spectator && cl_fakename.string[0] && !strchr(s, '\x0d') /* explicit $\ in message overrides cl_fakename */) { char buf[1024]; Cmd_ExpandString (cl_fakename.string, buf); strcpy (buf, TP_ParseMacroString (buf)); Q_snprintf (sendtext, sizeof(sendtext), "\x0d%s: ", TP_ParseFunChars(buf, true)); } strlcat (sendtext, text, sizeof(sendtext)); if (sendtext[0] < 32) SZ_Print (&cls.netchan.message, "\""); // add quotes so that old servers parse the message correctly SZ_Print (&cls.netchan.message, sendtext); if (sendtext[0] < 32) SZ_Print (&cls.netchan.message, "\""); // add quotes so that old servers parse the message correctly }
/* =================== Cmd_ForwardToServer adds the current command line as a clc_stringcmd to the client message. things like godmode, noclip, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded. =================== */ void Cmd_ForwardToServer (void) { if (cls.state == ca_disconnected) { Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0)); return; } if (cls.demoplayback) return; // not really connected MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, Cmd_Argv(0)); if (Cmd_Argc() > 1) { SZ_Print (&cls.netchan.message, " "); SZ_Print (&cls.netchan.message, Cmd_Args()); } }
/* =================== Cmd_ForwardToServer adds the current command line as a clc_stringcmd to the client message. things like godmode, noclip, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded. =================== */ void Cmd_ForwardToServer (void) { char *cmd; cmd = Cmd_Argv(0); if (cls.state <= ca_connected || *cmd == '-' || *cmd == '+') { Com_Printf ("Unknown command \"%s\"\n", cmd); return; } MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, cmd); if (Cmd_Argc() > 1) { SZ_Print (&cls.netchan.message, " "); SZ_Print (&cls.netchan.message, Cmd_Args()); } }
/* =================== Cmd_ForwardToServer adds the current command line as a clc_stringcmd to the client message. things like kill, say, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded. =================== */ void Cmd_ForwardToServer (void) { char *s; if (cls.state == ca_disconnected) { Com_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0)); return; } MSG_WriteByte (&cls.netchan.message, clc_stringcmd); // lowercase command for (s=Cmd_Argv(0) ; *s ; s++) *s = (char)tolower(*s); SZ_Print (&cls.netchan.message, Cmd_Argv(0)); if (Cmd_Argc() > 1) { SZ_Print (&cls.netchan.message, " "); SZ_Print (&cls.netchan.message, Cmd_Args()); } }
/* CL_Cmd_ForwardToServer Sends the entire command line over to the server */ void CL_Cmd_ForwardToServer (void) { if (cls.state < ca_connected) { Sys_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0)); return; } if (cls.demoplayback) return; // not really connected MSG_WriteByte (&cls.message, clc_stringcmd); if (strcasecmp (Cmd_Argv (0), "cmd") != 0) { SZ_Print (&cls.message, Cmd_Argv (0)); SZ_Print (&cls.message, " "); } if (Cmd_Argc () > 1) SZ_Print (&cls.message, Cmd_Args (1)); else SZ_Print (&cls.message, "\n"); }
void CL_ForwardToServer_f(void) { if ((cls.state != ca_connected) && (cls.state != ca_active)) { Com_Printf("Can't \"%s\", not connected\n", Cmd_Argv(0)); return; } /* don't forward the first argument */ if (Cmd_Argc() > 1) { MSG_WriteByte(&cls.netchan.message, clc_stringcmd); SZ_Print(&cls.netchan.message, Cmd_Args()); } }
/* ================== CL_UserinfoChanged Cvar system calls this when a CVAR_USERINFO cvar changes ================== */ void CL_UserinfoChanged (char *key, char *string) { char *s; s = TP_ParseFunChars (string, false); if (strcmp(s, Info_ValueForKey (cls.userinfo, key))) { Info_SetValueForKey (cls.userinfo, key, s, MAX_INFO_STRING); if (cls.state >= ca_connected) { MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, va("setinfo \"%s\" \"%s\"\n", key, s)); } } }
// don't forward the first argument static void CL_Cmd_ForwardToServer_f (void) { if (cls.state == ca_disconnected) { Sys_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0)); return; } if (strcasecmp (Cmd_Argv (1), "snap") == 0) { Cbuf_InsertText (cl_cbuf, "snap\n"); return; } if (cls.demoplayback) return; // not really connected if (Cmd_Argc () > 1) { MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, Cmd_Args (1)); } }
/* ===================== CL_Download_f ===================== */ void CL_Download_f (void) { if (cls.state == ca_disconnected) { Com_Printf ("Must be connected.\n"); return; } if (Cmd_Argc() != 2) { Com_Printf ("Usage: download <datafile>\n"); return; } Q_snprintf (cls.downloadname, sizeof(cls.downloadname), "%s", Cmd_Argv(1)); strcpy(cls.downloadtempname, cls.downloadname); cls.download = FS_Open (cls.downloadname, "wb", false, false); cls.downloadtype = dl_single; MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, va("download %s\n",Cmd_Argv(1))); }
/* CL_Cmd_ForwardToServer adds the current command line as a clc_stringcmd to the client message. things like godmode, noclip, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded. */ void CL_Cmd_ForwardToServer (void) { if (cls.state == ca_disconnected) { Sys_Printf ("Can't \"%s\", not connected\n", Cmd_Argv (0)); return; } if (cls.demoplayback) return; // not really connected MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, Cmd_Argv (0)); if (Cmd_Argc () > 1) { SZ_Print (&cls.netchan.message, " "); if (!strcasecmp (Cmd_Argv (0), "say") || !strcasecmp (Cmd_Argv (0), "say_team")) { const char *s; s = Team_ParseSay (Cmd_Args (1)); if (*s && *s < 32 && *s != 10) { // otherwise the server would eat leading characters // less than 32 or greater than 127 SZ_Print (&cls.netchan.message, "\""); SZ_Print (&cls.netchan.message, s); SZ_Print (&cls.netchan.message, "\""); } else SZ_Print (&cls.netchan.message, s); return; } SZ_Print (&cls.netchan.message, Cmd_Args (1)); } }
/* ===================== CL_ParseDownload A download message has been received from the server ===================== */ void CL_ParseDownload (sizebuf_t *msg, qboolean dataIsCompressed) { int size, percent; char name[MAX_OSPATH]; // int r; // read the data size = MSG_ReadShort (msg); percent = MSG_ReadByte (msg); if (size < 0) { if (size == -1) Com_Printf ("Server does not have this file.\n"); else Com_Printf ("Bad download data from server.\n"); cls.downloadtempname[0] = 0; cls.downloadname[0] = 0; cls.failed_download = true; if (cls.download) { // if here, we tried to resume a file but the server said no fclose (cls.download); cls.download = NULL; } CL_RequestNextDownload (); return; } // open the file if not opened yet if (!cls.download) { if (!cls.downloadtempname[0]) { Com_Printf ("Received download packet without request. Ignored.\n"); msg->readcount += size; return; } CL_DownloadFileName(name, sizeof(name), cls.downloadtempname); FS_CreatePath (name); cls.download = fopen (name, "wb"); if (!cls.download) { msg->readcount += size; Com_Printf ("Failed to open %s\n", cls.downloadtempname); CL_RequestNextDownload (); return; } } if (dataIsCompressed) { uint16 uncompressedLen; byte uncompressed[0xFFFF]; uncompressedLen = MSG_ReadShort (msg); if (!uncompressedLen) Com_Error (ERR_DROP, "uncompressedLen == 0"); ZLibDecompress (msg->data + msg->readcount, size, uncompressed, uncompressedLen, -15); fwrite (uncompressed, 1, uncompressedLen, cls.download); Com_DPrintf ("svc_zdownload(%s): %d -> %d\n", cls.downloadname, size, uncompressedLen); } else { fwrite (msg->data + msg->readcount, 1, size, cls.download); } //fwrite (net_message.data + net_message.readcount, 1, size, cls.download); msg->readcount += size; if (percent != 100) { // request next block // change display routines by zoid cls.downloadpercent = percent; MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, "nextdl"); } else { CL_FinishDownload(); // get another file if needed CL_RequestNextDownload (); } }
/* ===================== CL_ParseDownload A download message has been received from the server ===================== */ void CL_ParseDownload(void) { int size, percent; char name[MAX_OSPATH]; int r; // read the data size = MSG_ReadShort(&net_message); percent = MSG_ReadByte(&net_message); if (size == -1) { Com_Printf("Server does not have this file.\n"); if (cls.download) { // if here, we tried to resume a file but the server said no fclose(cls.download); cls.download = NULL; } CL_RequestNextDownload(); return; } // open the file if not opened yet if (!cls.download) { CL_DownloadFileName(name, sizeof(name), cls.downloadtempname); FS_CreatePath(name); cls.download = fopen(name, "wb"); if (!cls.download) { net_message.readcount += size; Com_Printf("Failed to open %s\n", cls.downloadtempname); CL_RequestNextDownload(); return; } } fwrite(net_message.data + net_message.readcount, 1, size, cls.download); net_message.readcount += size; if (percent != 100) { // request next block // change display routines by zoid #if 0 Com_Printf ("."); if (10*(percent/10) != cls.downloadpercent) { cls.downloadpercent = 10*(percent/10); Com_Printf ("%i%%", cls.downloadpercent); } #endif cls.downloadpercent = percent; MSG_WriteByte(&cls.netchan.message, clc_stringcmd); SZ_Print(&cls.netchan.message, "nextdl"); } else { char oldn[MAX_OSPATH]; char newn[MAX_OSPATH]; // Com_Printf ("100%%\n"); fclose(cls.download); // rename the temp file to it's final name CL_DownloadFileName(oldn, sizeof(oldn), cls.downloadtempname); CL_DownloadFileName(newn, sizeof(newn), cls.downloadname); r = rename(oldn, newn); if (r) Com_Printf("failed to rename.\n"); cls.download = NULL; cls.downloadpercent = 0; // get another file if needed CL_RequestNextDownload(); } }
/* ================= Mod_LoadAliasModel ================= */ void Mod_LoadAliasModel (model_t *mod, void *buffer) { int i, j; mdl_t *pinmodel; stvert_t *pinstverts; dtriangle_t *pintriangles; int version, numframes; int size; daliasframetype_t *pframetype; daliasskintype_t *pskintype; int start, end, total; if (!strcmp(loadmodel->name, "progs/player.mdl") || !strcmp(loadmodel->name, "progs/eyes.mdl")) { unsigned short crc; byte *p; int len; char st[40]; CRC_Init(&crc); for (len = com_filesize, p = buffer; len; len--, p++) CRC_ProcessByte(&crc, *p); sprintf(st, "%d", (int) crc); Info_SetValueForKey (cls.userinfo, !strcmp(loadmodel->name, "progs/player.mdl") ? pmodel_name : emodel_name, st, MAX_INFO_STRING); if (cls.state >= ca_connected) { MSG_WriteByte (&cls.netchan.message, clc_stringcmd); sprintf(st, "setinfo %s %d", !strcmp(loadmodel->name, "progs/player.mdl") ? pmodel_name : emodel_name, (int)crc); SZ_Print (&cls.netchan.message, st); } } start = Hunk_LowMark (); pinmodel = (mdl_t *)buffer; version = LittleLong (pinmodel->version); if (version != ALIAS_VERSION) Sys_Error ("%s has wrong version number (%i should be %i)", mod->name, version, ALIAS_VERSION); // // allocate space for a working header, plus all the data except the frames, // skin and group info // size = sizeof (aliashdr_t) + (LittleLong (pinmodel->numframes) - 1) * sizeof (pheader->frames[0]); pheader = Hunk_AllocName (size, loadname); mod->flags = LittleLong (pinmodel->flags); // // endian-adjust and copy the data, starting with the alias model header // pheader->boundingradius = LittleFloat (pinmodel->boundingradius); pheader->numskins = LittleLong (pinmodel->numskins); pheader->skinwidth = LittleLong (pinmodel->skinwidth); pheader->skinheight = LittleLong (pinmodel->skinheight); if (pheader->skinheight > MAX_LBM_HEIGHT) Sys_Error ("model %s has a skin taller than %d", mod->name, MAX_LBM_HEIGHT); pheader->numverts = LittleLong (pinmodel->numverts); if (pheader->numverts <= 0) Sys_Error ("model %s has no vertices", mod->name); if (pheader->numverts > MAXALIASVERTS) Sys_Error ("model %s has too many vertices", mod->name); pheader->numtris = LittleLong (pinmodel->numtris); if (pheader->numtris <= 0) Sys_Error ("model %s has no triangles", mod->name); pheader->numframes = LittleLong (pinmodel->numframes); numframes = pheader->numframes; if (numframes < 1) Sys_Error ("Mod_LoadAliasModel: Invalid # of frames: %d\n", numframes); pheader->size = LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO; mod->synctype = LittleLong (pinmodel->synctype); mod->numframes = pheader->numframes; for (i=0 ; i<3 ; i++) { pheader->scale[i] = LittleFloat (pinmodel->scale[i]); pheader->scale_origin[i] = LittleFloat (pinmodel->scale_origin[i]); pheader->eyeposition[i] = LittleFloat (pinmodel->eyeposition[i]); } // // load the skins // pskintype = (daliasskintype_t *)&pinmodel[1]; pskintype = Mod_LoadAllSkins (pheader->numskins, pskintype); // // load base s and t vertices // pinstverts = (stvert_t *)pskintype; for (i=0 ; i<pheader->numverts ; i++) { stverts[i].onseam = LittleLong (pinstverts[i].onseam); stverts[i].s = LittleLong (pinstverts[i].s); stverts[i].t = LittleLong (pinstverts[i].t); } // // load triangle lists // pintriangles = (dtriangle_t *)&pinstverts[pheader->numverts]; for (i=0 ; i<pheader->numtris ; i++) { triangles[i].facesfront = LittleLong (pintriangles[i].facesfront); for (j=0 ; j<3 ; j++) { triangles[i].vertindex[j] = LittleLong (pintriangles[i].vertindex[j]); } } // // load the frames // posenum = 0; pframetype = (daliasframetype_t *)&pintriangles[pheader->numtris]; for (i=0 ; i<numframes ; i++) { aliasframetype_t frametype; frametype = LittleLong (pframetype->type); if (frametype == ALIAS_SINGLE) { pframetype = (daliasframetype_t *) Mod_LoadAliasFrame (pframetype + 1, &pheader->frames[i]); } else { pframetype = (daliasframetype_t *) Mod_LoadAliasGroup (pframetype + 1, &pheader->frames[i]); } } pheader->numposes = posenum; mod->type = mod_alias; // FIXME: do this right mod->mins[0] = mod->mins[1] = mod->mins[2] = -16; mod->maxs[0] = mod->maxs[1] = mod->maxs[2] = 16; // // build the draw lists // GL_MakeAliasModelDisplayLists (mod, pheader); // // move the complete, relocatable alias model to the cache // end = Hunk_LowMark (); total = end - start; Cache_Alloc (&mod->cache, total, loadname); if (!mod->cache.data) return; memcpy (mod->cache.data, pheader, total); Hunk_FreeToLowMark (start); }
/* ================== SCR_RSShot_f ================== */ void SCR_RSShot_f (void) { int x, y; unsigned char *src, *dest; char pcxname[80]; #if 0 int i; char checkname[MAX_OSPATH]; #endif unsigned char *newbuf; //, *srcbuf; // int srcrowbytes; int w, h; int dx, dy, dex, dey, nx; int r, b, g; int count; float fracw, frach; char st[80]; time_t now; if (CL_IsUploading()) return; // already one pending if (cls.state < ca_onserver) return; // gotta be connected if (!scr_allowsnap.value) { MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, "snap\n"); Con_Printf("Refusing remote screen shot request.\n"); return; } Con_Printf("Remote screen shot requested.\n"); #if 0 // // find a file name to save it to // strcpy(pcxname,"mquake00.pcx"); for (i=0 ; i<=99 ; i++) { pcxname[6] = i/10 + '0'; pcxname[7] = i%10 + '0'; #if defined (__APPLE__) || defined (MACOSX) snprintf (checkname, MAX_OSPATH, "%s/%s", com_gamedir, pcxname); #else sprintf (checkname, "%s/%s", com_gamedir, pcxname); #endif /* __APPLE__ || MACOSX */ if (Sys_FileTime(checkname) == -1) break; // file doesn't exist } if (i==100) { Con_Printf ("SCR_ScreenShot_f: Couldn't create a PCX"); return; } #endif // // save the pcx file // D_EnableBackBufferAccess (); // enable direct drawing of console to back // buffer w = (vid.width < RSSHOT_WIDTH) ? vid.width : RSSHOT_WIDTH; h = (vid.height < RSSHOT_HEIGHT) ? vid.height : RSSHOT_HEIGHT; fracw = (float)vid.width / (float)w; frach = (float)vid.height / (float)h; newbuf = malloc(w*h); for (y = 0; y < h; y++) { dest = newbuf + (w * y); for (x = 0; x < w; x++) { r = g = b = 0; dx = x * fracw; dex = (x + 1) * fracw; if (dex == dx) dex++; // at least one dy = y * frach; dey = (y + 1) * frach; if (dey == dy) dey++; // at least one count = 0; for (/* */; dy < dey; dy++) { src = vid.buffer + (vid.rowbytes * dy) + dx; for (nx = dx; nx < dex; nx++) { r += host_basepal[*src * 3]; g += host_basepal[*src * 3+1]; b += host_basepal[*src * 3+2]; src++; count++; } } r /= count; g /= count; b /= count; *dest++ = MipColor(r, g, b); } } time(&now); strcpy(st, ctime(&now)); st[strlen(st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - ((int) strlen(st))*8, 0, w); strncpy(st, cls.servername, sizeof(st)); st[sizeof(st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - ((int) strlen(st))*8, 10, w); strncpy(st, name.string, sizeof(st)); st[sizeof(st) - 1] = 0; SCR_DrawStringToSnap (st, newbuf, w - ((int) strlen(st))*8, 20, w); WritePCXfile (pcxname, newbuf, w, h, w, host_basepal, true); free(newbuf); D_DisableBackBufferAccess (); // for adapters that can't stay mapped in // for linear writes all the time // Con_Printf ("Wrote %s\n", pcxname); Con_Printf ("Sending shot to server...\n"); }
// don't forward the first argument void CL_ForwardToServer_f (void) { // Added by VVD { char *server_string, client_time_str[9]; int i, server_string_len; extern cvar_t cl_crypt_rcon; time_t client_time; // Added by VVD } if (cls.mvdplayback == QTV_PLAYBACK) { QTV_Cl_ForwardToServer_f(); return; } if (cls.state == ca_disconnected) { Com_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0)); return; } if (cls.demoplayback) return; // not really connected if (Cmd_Argc() > 1) { if (strcasecmp(Cmd_Argv(1), "snap") == 0) { SCR_RSShot_f (); return; } //bliP -> if (strcasecmp(Cmd_Argv(1), "fileul") == 0) { CL_StartFileUpload (); return; } //<- MSG_WriteByte (&cls.netchan.message, clc_stringcmd); /* johnnycz: disabled due to security reasons -- fixme if (strcasecmp(Cmd_Argv(1), "download") == 0 && Cmd_Argc() > 2) { strlcpy(cls.downloadname, Cmd_Argv(2), sizeof(cls.downloadname)); COM_StripExtension(cls.downloadname, cls.downloadtempname); strlcat(cls.downloadtempname, ".tmp", sizeof(cls.downloadtempname)); cls.downloadtype = dl_single; //snprintf (cls.downloadname, sizeof(cls.downloadname), "%s", Cmd_Argv(2)); //strlcpy (cls.downloadtempname, cls.downloadname, sizeof(cls.downloadtempname)); } */ // Added by VVD { if (cl_crypt_rcon.value && strcasecmp(Cmd_Argv(1), "techlogin") == 0 && Cmd_Argc() > 2) { time(&client_time); for (client_time_str[0] = i = 0; i < sizeof(client_time); i++) { char tmp[3]; snprintf(tmp, sizeof(tmp), "%02X", (unsigned int)((client_time >> (i * 8)) & 0xFF)); strlcat(client_time_str, tmp, sizeof(client_time_str)); } server_string_len = Cmd_Argc() + strlen(Cmd_Argv(1)) + DIGEST_SIZE * 2 + 16; for (i = 3; i < Cmd_Argc(); ++i) server_string_len += strlen(Cmd_Argv(i)); server_string = (char *) Q_malloc(server_string_len); SHA1_Init(); SHA1_Update((unsigned char *)Cmd_Argv(1)); SHA1_Update((unsigned char *)" "); SHA1_Update((unsigned char *)Cmd_Argv(2)); SHA1_Update((unsigned char *)client_time_str); SHA1_Update((unsigned char *)" "); for (i = 3; i < Cmd_Argc(); ++i) { SHA1_Update((unsigned char *)Cmd_Argv(i)); SHA1_Update((unsigned char *)" "); } snprintf(server_string, server_string_len, "%s %s%s ", Cmd_Argv(1), SHA1_Final(), client_time_str); for (i = 3; i < Cmd_Argc(); ++i) { strlcat(server_string, Cmd_Argv(i), server_string_len); strlcat(server_string, " ", server_string_len); } SZ_Print (&cls.netchan.message, server_string); Q_free(server_string); } else
void EXT_FUNC SZ_Print_api(sizebuf_t *buf, const char *data) { SZ_Print(buf, data); }
/* <18805> ../engine/cvar.c:198 */ void EXT_FUNC Cvar_DirectSet_internal(struct cvar_s *var, const char *value) { if (!var || !value) { return; } const char *pszValue = value; char szNew[MAX_CVAR_VALUE]; szNew[0] = 0; if (var->flags & FCVAR_PRINTABLEONLY) { if (Q_UnicodeValidate(value)) { Q_strncpy(szNew, value, ARRAYSIZE(szNew) - 1); szNew[ARRAYSIZE(szNew) - 1] = 0; } else { // Copy only printable chars // TODO: Why not UTF-8 too? const char *pS = pszValue; char *pD = szNew; while (*pS) { if (*pS < 32 || *pS > 126) { pS++; continue; } *pD++ = *pS++; } *pD = 0; } if (!Q_UnicodeValidate(szNew)) { // Call the artillery Q_UnicodeRepair(szNew); } if (szNew[0] == 0) { Q_strcpy(szNew, "empty"); } pszValue = szNew; } if (var->flags & FCVAR_NOEXTRAWHITEPACE) { if (pszValue != szNew) { Q_strncpy(szNew, value, ARRAYSIZE(szNew) - 1); szNew[ARRAYSIZE(szNew) - 1] = 0; } Q_StripUnprintableAndSpace(szNew); pszValue = szNew; } qboolean changed = Q_strcmp(var->string, pszValue); if (var->flags & FCVAR_USERINFO) { if (g_pcls.state == ca_dedicated) { char *info = Info_Serverinfo(); Info_SetValueForKey(info, var->name, pszValue, MAX_INFO_STRING); SV_BroadcastCommand("fullserverinfo \"%s\"\n", info); } #ifndef SWDS else { Info_SetValueForKey(g_pcls.userinfo, var->name, pszValue, MAX_INFO_STRING); if (changed && g_pcls.state >= ca_connected) { MSG_WriteByte(&g_pcls.netchan.message, clc_stringcmd); SZ_Print(&g_pcls.netchan.message, va("setinfo \"%s\" \"%s\"\n", var->name, pszValue)); } } #endif } if (changed && var->flags & FCVAR_SERVER) { if (!(var->flags & FCVAR_UNLOGGED)) { if (var->flags & FCVAR_PROTECTED) { Log_Printf("Server cvar \"%s\" = \"%s\"\n", var->name, "***PROTECTED***"); SV_BroadcastPrintf("\"%s\" changed to \"%s\"\n", var->name, "***PROTECTED***"); } else { Log_Printf("Server cvar \"%s\" = \"%s\"\n", var->name, pszValue); SV_BroadcastPrintf("\"%s\" changed to \"%s\"\n", var->name, pszValue); } } if (!(var->flags & FCVAR_PROTECTED)) { Steam_SetCVar(var->name, pszValue); } else if (pszValue[0] && Q_stricmp(pszValue, "none")) { Steam_SetCVar(var->name, "1"); } else { Steam_SetCVar(var->name, "0"); } } Z_Free(var->string); var->string = (char *)Z_Malloc(Q_strlen(pszValue) + 1); Q_strcpy(var->string, pszValue); var->value = (float)Q_atof(var->string); }
/* * A download message has been received from the server */ void CL_ParseDownload (void) { int size, percent; char name[MAX_OSPATH]; int r; /* read the data */ size = MSG_ReadShort (&net_message); percent = MSG_ReadByte (&net_message); if (size == -1) { Com_Printf ("Server does not have this file.\n"); if (cls.download) { /* if here, we tried to resume a file but the server said no */ fclose (cls.download); cls.download = NULL; } CL_RequestNextDownload (); return; } /* open the file if not opened yet */ if (!cls.download) { CL_DownloadFileName(name, sizeof(name), cls.downloadtempname); FS_CreatePath (name); cls.download = fopen (name, "wb"); if (!cls.download) { net_message.readcount += size; Com_Printf ("Failed to open %s\n", cls.downloadtempname); CL_RequestNextDownload (); return; } } fwrite (net_message.data + net_message.readcount, 1, size, cls.download); net_message.readcount += size; if (percent != 100) { /* request next block */ cls.downloadpercent = percent; MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, "nextdl"); } else { char oldn[MAX_OSPATH]; char newn[MAX_OSPATH]; fclose (cls.download); /* rename the temp file to it's final name */ CL_DownloadFileName(oldn, sizeof(oldn), cls.downloadtempname); CL_DownloadFileName(newn, sizeof(newn), cls.downloadname); r = rename (oldn, newn); if (r) Com_Printf ("failed to rename.\n"); cls.download = NULL; cls.downloadpercent = 0; /* get another file if needed */ CL_RequestNextDownload (); } }
/* ============ Cvar_Set ============ */ void Cvar_Set (const char *var_name, const char *value) { cvar_t *var; size_t varlen; var = Cvar_FindVar (var_name); if (!var) { // there is an error in C code if this happens Con_Printf ("%s: variable %s not found\n", __thisfunc__, var_name); return; } if ( var->flags & (CVAR_ROM|CVAR_LOCKED) ) return; // cvar is marked read-only or locked temporarily if (var->flags & CVAR_REGISTERED) { if ( !strcmp(var->string, value) ) return; // no change } else { var->flags |= CVAR_REGISTERED; } varlen = strlen(value); if (var->string == NULL) { var->string = (char *) Z_Malloc (varlen + 1, Z_MAINZONE); } else if (strlen(var->string) != varlen) { Z_Free ((void *)var->string); // free the old value string var->string = (char *) Z_Malloc (varlen + 1, Z_MAINZONE); } memcpy ((char *)var->string, value, varlen + 1); var->value = atof (var->string); var->integer = (int) var->value; // handle notifications #if defined (H2W) # if defined(SERVERONLY) if (var->flags & CVAR_SERVERINFO) { Info_SetValueForKey (svs.info, var_name, value, MAX_SERVERINFO_STRING); SV_BroadcastCommand ("fullserverinfo \"%s\"\n", svs.info); } # else /* HWCL */ if (var->flags & CVAR_USERINFO) { Info_SetValueForKey (cls.userinfo, var_name, value, MAX_INFO_STRING); if (cls.state >= ca_connected) { MSG_WriteByte (&cls.netchan.message, clc_stringcmd); SZ_Print (&cls.netchan.message, va("setinfo \"%s\" \"%s\"\n", var_name, value)); } } # endif #else /* ! H2W */ if (var->flags & CVAR_NOTIFY) { if (sv.active) SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var_name, value); } #endif /* H2W */ // don't allow deathmatch and coop at the same time #if !defined(H2W) || defined(SERVERONLY) if ( !strcmp(var->name, deathmatch.name) ) { if (var->integer != 0) Cvar_Set("coop", "0"); } else if ( !strcmp(var->name, coop.name) ) { if (var->integer != 0) Cvar_Set("deathmatch", "0"); } #endif /* coop && deathmatch */ }