// // FL_ChangeDirUp - cd .. // void FL_ChangeDirUp(filelist_t *fl) { int current_len = 0; // No point doing anything. if (strlen(fl->current_dir) < 2) { return; } // Get the name of the directory we're leaving, so that we can highlight it // in the file list of it's parent. (makes it easier keep track of where you are) { current_len = strlen(fl->current_dir); fl->cdup_find = true; #ifdef WITH_ZIP if (fl->in_archive) { strlcpy (fl->cdup_name, COM_SkipPath(fl->current_archive), sizeof(fl->cdup_name)); } else #endif // WITH_ZIP { strlcpy (fl->cdup_name, COM_SkipPath(fl->current_dir), sizeof(fl->cdup_name)); } // fl->cdup_name will be: // the_directory_were_leaving // If the full path was: // c:\quake\qw\the_directory_were_leaving } }
char *FMod_Response_Text(void) { static char buf[512]; int i, count; qbool relevent; strlcpy(buf, "modified:", sizeof(buf)); for (i = count = 0; i < check_models_num; i++) { relevent = (cl.teamfortress && (check_models[i].flags & FMOD_TF)) || (!cl.teamfortress && (check_models[i].flags & FMOD_DM)); if (check_models[i].checked && check_models[i].modified && relevent ) { if (strlen (buf) < 240) { strlcat (buf, va(" %s", COM_SkipPath (check_models[i].name)), sizeof (buf)); count++; } else { strlcat (buf, " & more...", sizeof (buf)); break; } } } if (!count) strlcpy (buf, "all models ok", sizeof (buf)); return buf; }
void COM_StripFilename(char *in, char *out) { char *end; Q_strncpyz(out, in, strlen(in) + 1); end = COM_SkipPath(out); *end = 0; }
void FMod_Response (void) { int i, count; char buf[512] = {'m', 'o', 'd', 'i', 'f', 'i', 'e', 'd', ':', '\0'}; qbool relevent; for (i = count = 0; i < check_models_num; i++) { relevent = (cl.teamfortress && (check_models[i].flags & FMOD_TF)) || (!cl.teamfortress && (check_models[i].flags & FMOD_DM)); if (check_models[i].checked && check_models[i].modified && relevent ) { if (strlen (buf) < 240) { strlcat (buf, va(" %s", COM_SkipPath (check_models[i].name)), sizeof (buf)); count++; } else { strlcat (buf, " & more...", sizeof (buf)); break; } } } if (!count) strlcpy (buf, "all models ok", sizeof (buf)); Cbuf_AddText (va ("%s %s\n", cls.state == ca_disconnected ? "echo" : "say", buf)); }
static void *FSGZIP_LoadGZipFile(vfsfile_t *gziphandle, const char *desc) { gzipfile_t *gzip; const char *base; char *ext; int fd; gzip = Q_calloc(1, sizeof(*gzip)); strlcpy(gzip->filename, desc, sizeof(gzip->filename)); if (gziphandle == NULL) goto fail; gzip->raw = gziphandle; fd = fileno(((vfsosfile_t *)gziphandle)->handle); // <-- ASSUMPTION! that file is OS gzip->handle = (vfsfile_t *)gzdopen(dup(fd), "r"); gzip->references = 1; /* Remove the .gz from the file.name */ base = COM_SkipPath(desc); ext = COM_FileExtension(desc); if (strcmp(ext, "gz") == 0) { COM_StripExtension(base, gzip->file.name, sizeof(gzip->file.name)); } else { strlcpy(gzip->file.name, base, sizeof(gzip->file.name)); } return gzip; fail: // Q_free is safe to call on NULL pointers Q_free(gzip); return NULL; }
/* =============== Svcmd_BotList_f =============== */ void Svcmd_BotList_f( void ) { int i; char name[MAX_NETNAME]; char funname[MAX_NETNAME]; char model[MAX_QPATH]; char personality[MAX_QPATH]; trap->Print("name model personality funname\n"); for (i = 0; i < level.bots.num; i++) { Q_strncpyz(name, Info_ValueForKey( level.bots.infos[i], "name" ), sizeof( name )); if ( !*name ) { Q_strncpyz(name, "Padawan", sizeof( name )); } Q_strncpyz(funname, Info_ValueForKey( level.bots.infos[i], "funname"), sizeof( funname )); if ( !*funname ) { funname[0] = '\0'; } Q_strncpyz(model, Info_ValueForKey( level.bots.infos[i], "model" ), sizeof( model )); if ( !*model ) { Q_strncpyz(model, DEFAULT_MODEL"/default", sizeof( model )); } Q_strncpyz(personality, Info_ValueForKey( level.bots.infos[i], "personality"), sizeof( personality )); if (!*personality ) { Q_strncpyz(personality, "botfiles/kyle.jkb", sizeof( personality )); } trap->Print("%-16s %-16s %-20s %-20s\n", name, model, COM_SkipPath(personality), funname); } }
void CL_LoadLocs(void) { location_t *newloc; vec3_t pos; char *file; char *end; char name[MAX_QPATH]; // if (!strcmp(LocationLevel, cl.model_name[1])) // return; while(location) { newloc = location->next; Z_Free(location); location = newloc; } strcpy(LocationLevel, cl.model_name[1]); COM_StripExtension(COM_SkipPath(LocationLevel), name); file = COM_LoadTempFile(va("locs/%s.loc", name)); if (!file) return; for(;;) { file = COM_Parse(file); pos[0] = atof(com_token)/8; file = COM_Parse(file); pos[1] = atof(com_token)/8; file = COM_Parse(file); pos[2] = atof(com_token)/8; while(*file && *file <= '\0') file++; if (!file) return; end = strchr(file, '\n'); if (!end) { end = file + strlen(file); } newloc = Z_Malloc(sizeof(location_t) + end-file+1); newloc->next = location; location = newloc; Q_strncpyz(newloc->name, file, end-file); VectorCopy(pos, newloc->pos); if (!*end) return; file = end+1; } }
// Standard naming for screenshots/demos static char *demoAutoGenerateDefaultFilename(void) { qtime_t ct; const char *pszServerInfo = cl.gameState.stringData + cl.gameState.stringOffsets[CS_SERVERINFO]; Com_RealTime(&ct); return va("%d-%02d-%02d-%02d%02d%02d-%s", 1900+ct.tm_year, ct.tm_mon+1,ct.tm_mday, ct.tm_hour, ct.tm_min, ct.tm_sec, COM_SkipPath(Info_ValueForKey(pszServerInfo, "mapname"))); }
/******** CIN_PlayCinematic arg0 - filename of bink video xpos - x origin ypos - y origin width - width of the movie window height - height of the movie window bits - CIN flags psAudioFile - audio file for movie (not used) Starts playing the given bink video file *********/ int CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits, const char *psAudioFile /* = NULL */) { char arg[MAX_OSPATH]; char* nameonly; int handle; // get a local copy of the name strcpy(arg,arg0); // remove path, find in list nameonly = COM_SkipPath(arg); // ja01 contains the text crawl, so we need to add on the right language suffix extern DWORD g_dwLanguage; if( Q_stricmp(nameonly, "ja01") == 0) { switch( g_dwLanguage ) { case XC_LANGUAGE_FRENCH: strcat(nameonly, "_f"); break; case XC_LANGUAGE_GERMAN: strcat(nameonly, "_d"); break; case XC_LANGUAGE_ENGLISH: default: strcat(nameonly, "_e"); break; } } for (handle = 0; handle < cinNumFiles; ++handle) { if (!Q_stricmp(cinFiles[handle].filename, nameonly)) break; } // Don't have the requested movie in our table? if (handle == cinNumFiles) { Com_Printf( "ERROR: Movie file %s not found!\n", nameonly ); return -1; } // Store off information about the movie in the right place. Don't // actually play them movie, CIN_RunCinematic takes care of that. cinFiles[handle].x = xpos; cinFiles[handle].y = ypos; cinFiles[handle].w = width; cinFiles[handle].h = height; cinFiles[handle].bits = bits; currentHandle = -1; return handle; }
int CT_Opt_Config_Key(int key, CTab_t *tab, CTabPage_t *page) { switch (MOpt_configpage_mode) { case MOCPM_SETTINGS: return Settings_Key(&settconfig, key); break; case MOCPM_CHOOSECONFIG: if (key == K_ENTER || key == K_MOUSE1) { Cbuf_AddText(va("cfg_load \"%s\"\n", COM_SkipPath(FL_GetCurrentEntry(&configs_filelist)->name))); MOpt_configpage_mode = MOCPM_SETTINGS; return true; } else if (key == K_ESCAPE || key == K_MOUSE2) { MOpt_configpage_mode = MOCPM_SETTINGS; return true; } else return FL_Key(&configs_filelist, key); case MOCPM_CHOOSESCRIPT: if (key == K_ENTER || key == K_MOUSE1) { Cbuf_AddText(va("exec \"cfg/%s\"\n", COM_SkipPath(FL_GetCurrentEntry(&configs_filelist)->name))); MOpt_configpage_mode = MOCPM_SETTINGS; return true; } else if (key == K_ESCAPE || key == K_MOUSE2) { MOpt_configpage_mode = MOCPM_SETTINGS; return true; } else return FL_Key(&configs_filelist, key); case MOCPM_ENTERFILENAME: if (key == K_ENTER || key == K_MOUSE1) { Cbuf_AddText(va("cfg_save \"%s\"\n", MOpt_FileNameInputBoxGetText())); MOpt_configpage_mode = MOCPM_SETTINGS; return true; } else if (key == K_ESCAPE || key == K_MOUSE2) { MOpt_configpage_mode = MOCPM_SETTINGS; return true; } else return MOpt_FileNameInputBoxKey(key); } return false; }
/* =============== Cmd_Exec_f =============== */ void Cmd_Exec_f (void) { char *f; int mark; char name[MAX_OSPATH]; if (Cmd_Argc () != 2) { Com_Printf ("exec <filename> : execute a script file\n"); return; } strlcpy (name, Cmd_Argv(1), sizeof(name) - 4); mark = Hunk_LowMark (); f = (char *)FS_LoadHunkFile (name); if (!f) { char *p; p = COM_SkipPath (name); if (!strchr (p, '.')) { // no extension, so try the default (.cfg) strcat (name, ".cfg"); f = (char *)FS_LoadHunkFile (name); } if (!f) { Com_Printf ("couldn't exec %s\n", Cmd_Argv(1)); return; } } if (cl_warncmd.value || developer.value) Com_Printf ("execing %s\n", name); #ifndef SERVERONLY if (cbuf_current == &cbuf_svc) { Cbuf_AddText (f); Cbuf_AddText ("\n"); } else #endif { Cbuf_InsertText ("\n"); Cbuf_InsertText (f); } Hunk_FreeToLowMark (mark); }
static void BG_FindWeaponFrames(TAnimInfoWeapon *animInfo, int choice) { if (!numWeaponFiles || !animInfo->mAnim[choice]) { animInfo->mNumFrames[choice] = -1; return; } for(int i=0;i<numWeaponFiles;i++) { char temp[256]; void *group = trap_GPG_GetSubGroups ( frameGroup[i] ); while ( group ) { char* name; // Get the name and break it down to just the filename without // and extension trap_GPG_GetName ( group, temp ); name = COM_SkipPath ( temp ); COM_StripExtension ( name, temp ); if ( strcmp ( temp, animInfo->mAnim[choice] ) == 0 ) { break; } group = trap_GPG_GetNext ( group ); } if (group) { trap_GPG_FindPairValue(group, "startframe", "0", temp); animInfo->mStartFrame[choice] = atoi(temp); trap_GPG_FindPairValue(group, "duration", "0", temp); animInfo->mNumFrames[choice] = atoi(temp); trap_GPG_FindPairValue(group, "fps", "0", temp); animInfo->mFPS[choice] = atoi(temp); animInfo->mNoteTracks[choice] = BG_FindNoteTracks(group); return; } } animInfo->mNumFrames[choice] = -1; }
// where label is (eg) "kejim_base"... // sboolean Music_DynamicDataAvailable(const char *psDynamicMusicLabel) { char sLevelName[MAX_QPATH]; Q_strncpyz(sLevelName,COM_SkipPath( const_cast<char*>( (psDynamicMusicLabel&&psDynamicMusicLabel[0])?psDynamicMusicLabel:gsLevelNameFromServer.c_str() ) ),sizeof(sLevelName)); strlwr(sLevelName); if (strlen(sLevelName)) // avoid error messages when there's no music waiting to be played and we try and restart it... { if (Music_ParseLeveldata(sLevelName)) { return !!( Music_GetBaseMusicFile( eBGRNDTRACK_EXPLORE ) && Music_GetBaseMusicFile( eBGRNDTRACK_ACTION ) ); } } return qfalse; }
void SaveConfig_f(void) { char filename[MAX_PATH] = {0}, *filename_ext, *backupname_ext; const char* arg1; size_t len; FILE *f; arg1 = COM_SkipPath(Cmd_Argv(1)); snprintf(filename, sizeof(filename) - 4, "%s", arg1[0] ? arg1 : "config.cfg"); // use config.cfg if no params was specified COM_ForceExtensionEx (filename, ".cfg", sizeof (filename)); if (cfg_backup.integer) { if (cfg_use_home.integer) // use home dir for cfg filename_ext = va("%s/%s", com_homedir, filename); else // use ezquake dir filename_ext = va("%s/ezquake/configs/%s", com_basedir, filename); if ((f = fopen(filename_ext, "r"))) { fclose(f); len = strlen(filename_ext) + 5; backupname_ext = (char *) Q_malloc(len); snprintf (backupname_ext, len, "%s.bak", filename_ext); if ((f = fopen(backupname_ext, "r"))) { fclose(f); remove(backupname_ext); } rename(filename_ext, backupname_ext); Q_free(backupname_ext); } } DumpConfig(filename); Com_Printf("Saving configuration to %s\n", filename); }
void G_LoadAnimFileSet( gentity_t *ent, const char *modelName ) { //load its animation config char animName[MAX_QPATH]; char *GLAName; char *slash = NULL; char *strippedName; if ( ent->playerModel == -1 ) { return; } //get the location of the animation.cfg GLAName = gi.G2API_GetGLAName( &ent->ghoul2[ent->playerModel] ); //now load and parse the animation.cfg, animsounds.cfg and set the animFileIndex if ( !GLAName) { Com_Printf( S_COLOR_RED"Failed find animation file name models/players/%s/animation.cfg\n", modelName ); strippedName="broken"; } else { Q_strncpyz( animName, GLAName, sizeof( animName ), qtrue ); slash = strrchr( animName, '/' ); if ( slash ) { *slash = 0; } strippedName = COM_SkipPath( animName ); } //now load and parse the animation.cfg, animsounds.cfg and set the animFileIndex if ( !G_ParseAnimFileSet( modelName, strippedName, &ent->client->clientInfo.animFileIndex ) ) { Com_Printf( S_COLOR_RED"Failed to load animation file set models/players/%s/animation.cfg\n", modelName ); } }
void NPC_PrecacheAnimationCFG( const char *NPC_type ) { char filename[MAX_QPATH]; const char *token; const char *value; const char *p; int junk; if ( !Q_stricmp( "random", NPC_type ) ) {//sorry, can't precache a random just yet return; } p = NPCParms; COM_BeginParseSession(); // look for the right NPC while ( p ) { token = COM_ParseExt( &p, qtrue ); if ( token[0] == 0 ) { return; } if ( !Q_stricmp( token, NPC_type ) ) { break; } SkipBracedSection( &p ); } if ( !p ) { return; } if ( G_ParseLiteral( &p, "{" ) ) { return; } // parse the NPC info block while ( 1 ) { token = COM_ParseExt( &p, qtrue ); if ( !token[0] ) { gi.Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'\n", NPC_type ); return; } if ( !Q_stricmp( token, "}" ) ) { break; } // legsmodel if ( !Q_stricmp( token, "legsmodel" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } //must copy data out of this pointer into a different part of memory because the funcs we're about to call will call COM_ParseExt Q_strncpyz( filename, value, sizeof( filename ), qtrue ); G_ParseAnimFileSet( filename, filename, &junk ); return; } // playerModel if ( !Q_stricmp( token, "playerModel" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } char animName[MAX_QPATH]; char *GLAName; char *slash = NULL; char *strippedName; int handle = gi.G2API_PrecacheGhoul2Model( va( "models/players/%s/model.glm", value ) ); if ( handle > 0 )//FIXME: isn't 0 a valid handle? { GLAName = gi.G2API_GetAnimFileNameIndex( handle ); if ( GLAName ) { Q_strncpyz( animName, GLAName, sizeof( animName ), qtrue ); slash = strrchr( animName, '/' ); if ( slash ) { *slash = 0; } strippedName = COM_SkipPath( animName ); //must copy data out of this pointer into a different part of memory because the funcs we're about to call will call COM_ParseExt Q_strncpyz( filename, value, sizeof( filename ), qtrue ); G_ParseAnimFileSet( value, strippedName, &junk );//qfalse ); //FIXME: still not precaching the animsounds.cfg? return; } } } } }
/* ================== CL_ParseServerInfo ================== */ void CL_ParseServerInfo(void) { char *level; const char *mapname; int i, maxlen; int nummodels, numsounds; char model_precache[MAX_MODELS][MAX_QPATH]; char sound_precache[MAX_SOUNDS][MAX_QPATH]; Con_DPrintf("Serverinfo packet received.\n"); // // wipe the client_state_t struct // CL_ClearState(); // parse protocol version number i = MSG_ReadLong(); if (!Protocol_Known(i)) { Con_Printf("Server returned unknown protocol version %i\n", i); return; } cl.protocol = i; // parse maxclients cl.maxclients = MSG_ReadByte(); if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD) { Con_Printf("Bad maxclients (%u) from server\n", cl.maxclients); return; } cl.players = Hunk_AllocName(cl.maxclients * sizeof(*cl.players), "players"); // parse gametype cl.gametype = MSG_ReadByte(); // parse signon message level = cl.levelname; maxlen = sizeof(cl.levelname); snprintf(level, maxlen, "%s", MSG_ReadString()); // seperate the printfs so the server message can have a color Con_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36" "\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); Con_Printf("%c%s\n", 2, level); Con_Printf("Using protocol %i\n", cl.protocol); // // first we go through and touch all of the precache data that still // happens to be in the cache, so precaching something else doesn't // needlessly purge it // // precache models memset(cl.model_precache, 0, sizeof(cl.model_precache)); for (nummodels = 1;; nummodels++) { char *in, *model; in = MSG_ReadString(); if (!in[0]) break; if (nummodels == max_models(cl.protocol)) { Host_Error("Server sent too many model precaches (max = %d)", max_models(cl.protocol)); return; } model = model_precache[nummodels]; maxlen = sizeof(model_precache[0]); snprintf(model, maxlen, "%s", in); Mod_TouchModel(model); } // precache sounds memset(cl.sound_precache, 0, sizeof(cl.sound_precache)); for (numsounds = 1;; numsounds++) { char *in, *sound; in = MSG_ReadString(); if (!in[0]) break; if (numsounds == max_sounds(cl.protocol)) { Host_Error("Server sent too many sound precaches (max = %d)", max_sounds(cl.protocol)); return; } sound = sound_precache[numsounds]; maxlen = sizeof(sound_precache[0]); snprintf(sound, maxlen, "%s", in); S_TouchSound(sound); } // copy the naked name of the map file to the cl structure mapname = COM_SkipPath(model_precache[1]); COM_StripExtension(mapname, cl.mapname, sizeof(cl.mapname)); // // now we try to load everything else until a cache allocation fails // for (i = 1; i < nummodels; i++) { cl.model_precache[i] = Mod_ForName(model_precache[i], false); if (cl.model_precache[i] == NULL) { Con_Printf("Model %s not found\n", model_precache[i]); return; } CL_KeepaliveMessage(); } S_BeginPrecaching(); for (i = 1; i < numsounds; i++) { cl.sound_precache[i] = S_PrecacheSound(sound_precache[i]); CL_KeepaliveMessage(); } S_EndPrecaching(); // local state cl_entities[0].model = cl.model_precache[1]; cl.worldmodel = BrushModel(cl_entities[0].model); R_NewMap(); Hunk_Check(); // make sure nothing is hurt noclip_anglehack = false; // noclip is turned off at start }
void SaveConfig_f(void) { SaveConfig(COM_SkipPath(Cmd_Argv(1))); }
/* ================= Mod_LoadQ3Model ================= */ void Mod_LoadQ3Model (model_t *mod, const void *buffer) { md3header_t *header; md3surface_t *surf; int i, j, picmip_flag; md3shader_t *shader; md3frame_t *frame; // md3ver_t *vert; byte *modeldata; const char **pathlist; const char *namelist[2]; char path[MAX_OSPATH]; header = (md3header_t *) buffer; if (header->version != 15) { Con_Printf ("\x02""ERROR: incorrect version of MD3 file %s\n", mod->name); return; } Con_DPrintf ("Loading md3 model...%s (%s)\n", header->filename, mod->name); frame = (md3frame_t *) ((byte *) header + header->frame_offs); for (i = 0; i < header->num_frames; i++, frame++) { VectorCopy (frame->pos, md3bboxmins); VectorCopy (frame->pos, md3bboxmaxs); for (j = 0; j < 3; j++) { if (frame->mins[j] < md3bboxmins[j]) md3bboxmins[j] = frame->mins[j]; if (frame->maxs[j] > md3bboxmaxs[j]) md3bboxmaxs[j] = frame->maxs[j]; } } #ifndef RQM_SV_ONLY picmip_flag = gl_picmip_all.value ? TEX_MIPMAP : 0; #else picmip_flag = 0; #endif surf = (md3surface_t *) ((byte *)header + header->surface_offs); for (i=0; i < header->num_surfaces; i++) { if (*(long *)surf->id != MD3IDHEADER) { Con_Printf ("\x02""MD3 bad surface for: %s\n", header->filename); break; } /*vert = (md3vert_t *) ((byte *) surf + surf->vert_offs); for (j=0; j < surf->num_surf_verts * surf->num_surf_frames; j++, vert++) { float lat; float lng; //convert verts from shorts to floats md3vert_mem_t *mem_vert = (md3vert_mem_t *)((byte *)mem_head + posn); md3vert_t *disk_vert = (md3vert_t *)((byte *)surf + surf->vert_offs + j * sizeof(md3vert_t)); mem_vert->vec[0] = (float)disk_vert->vec[0] / 64.0f; mem_vert->vec[1] = (float)disk_vert->vec[1] / 64.0f; mem_vert->vec[2] = (float)disk_vert->vec[2] / 64.0f; //work out normals lat = (disk_vert->normal + 255) * (2 * 3.141592654) / 255; lng = ((disk_vert->normal >> 8) & 255) * (2 * 3.141592654) / 255; mem_vert->normal[0] = cos (lat) * sin (lng); mem_vert->normal[1] = sin (lat) * sin (lng); mem_vert->normal[2] = cos (lng); } */ // load all the external textures: shader = (md3shader_t *)((byte *)surf + surf->shader_offs); for (j=0; j < surf->num_surf_shaders; j++, shader++) { #ifndef RQM_SV_ONLY //shader->index = GL_LoadTextureImage ("", shader->name, NULL, picmip_flag | TEX_BLEND, mod_loadpath->dir_level); namelist[0] = COM_SkipPath (shader->name); namelist[1] = NULL; if (namelist[0] != shader->name) { Q_strncpy (path, sizeof(path), shader->name, namelist[0]-shader->name); md3_paths[0] = path; pathlist = &md3_paths[0]; } else { pathlist = &md3_paths[1]; // no custom path } shader->index = GL_LoadTextureImage_MultiSource (pathlist, namelist, NULL, picmip_flag | TEX_BLEND, mod_loadpath->dir_level); if (!shader->index) { Con_Printf ("\x02""Model: %s Texture missing: %s\n", mod->name, shader->name); } #else shader->index = 0; #endif } surf = (md3surface_t *)((byte *)surf + surf->end_offs); } modeldata = Cache_Alloc (&mod->cache, header->end_offs, mod->name); if (!modeldata) { Con_DPrintf ("\x02""cache alloc failed...%s (%s)\n", header->filename, mod->name); return; //cache alloc failed } memcpy (modeldata, buffer, header->end_offs); mod->type = mod_md3; // mod->aliastype = MD3IDHEADER; mod->numframes = header->num_frames; mod->modhint = Mod_GetAliasHint (mod->name); mod->flags = header->flags; if (mod->modhint == MOD_HEAD) mod->flags |= EF_GIB; else mod->flags |= Mod_GetQ3ModelFlags (mod->name); VectorScale (md3bboxmaxs, 1.0/64.0, mod->maxs); VectorScale (md3bboxmins, 1.0/64.0, mod->mins); }
void PlayQWZDemo (void) { extern cvar_t qizmo_dir; STARTUPINFO si; PROCESS_INFORMATION pi; char *name; char qwz_name[256]; char cmdline[512]; char *p; if (hQizmoProcess) { Com_Printf ("Cannot unpack -- Qizmo still running!\n"); return; } name = Cmd_Argv(1); if (!strncmp(name, "../", 3) || !strncmp(name, "..\\", 3)) strlcpy (qwz_name, va("%s/%s", com_basedir, name+3), sizeof(qwz_name)); else if (name[0] == '/' || name[0] == '\\') strlcpy (qwz_name, va("%s/%s", cls.gamedir, name+1), sizeof(qwz_name)); else strlcpy (qwz_name, va("%s/%s", cls.gamedir, name), sizeof(qwz_name)); // Qizmo needs an absolute file name _fullpath (qwz_name, qwz_name, sizeof(qwz_name)-1); qwz_name[sizeof(qwz_name)-1] = 0; // check if the file exists cls.demofile = fopen (qwz_name, "rb"); if (!cls.demofile) { Com_Printf ("Couldn't open %s\n", name); return; } fclose (cls.demofile); strlcpy (tempqwd_name, qwz_name, sizeof(tempqwd_name)-4); #if 0 // the right way strcpy (tempqwd_name + strlen(tempqwd_name) - 4, ".qwd"); #else // the way Qizmo does it, sigh p = strstr (tempqwd_name, ".qwz"); if (!p) p = strstr (tempqwd_name, ".QWZ"); if (!p) p = tempqwd_name + strlen(tempqwd_name); strcpy (p, ".qwd"); #endif cls.demofile = fopen (tempqwd_name, "rb"); if (cls.demofile) { // .qwd already exists, so just play it cls.demoplayback = true; cls.state = ca_demostart; Netchan_Setup (NS_CLIENT, &cls.netchan, net_null, 0); cls.demotime = 0; return; } Com_Printf ("Unpacking %s...\n", COM_SkipPath(name)); // start Qizmo to unpack the demo memset (&si, 0, sizeof(si)); si.cb = sizeof(si); si.wShowWindow = SW_HIDE; si.dwFlags = STARTF_USESHOWWINDOW; strlcpy (cmdline, va("%s/%s/qizmo.exe -q -u -D \"%s\"", com_basedir, qizmo_dir.string, qwz_name), sizeof(cmdline)); if (!CreateProcess (NULL, cmdline, NULL, NULL, FALSE, 0/* | HIGH_PRIORITY_CLASS*/, NULL, va("%s/%s", com_basedir, qizmo_dir.string), &si, &pi)) { Com_Printf ("Couldn't execute %s/%s/qizmo.exe\n", com_basedir, qizmo_dir.string); return; } hQizmoProcess = pi.hProcess; qwz_unpacking = true; qwz_playback = true; // demo playback doesn't actually start yet, we just set // cls.demoplayback so that CL_StopPlayback() will be called // if CL_Disconnect() is issued cls.demoplayback = true; cls.demofile = NULL; cls.state = ca_demostart; Netchan_Setup (NS_CLIENT, &cls.netchan, net_null, 0); cls.demotime = 0; }
char *demoAutoFormat(const char* name) { const char *format; qboolean haveTag = qfalse; static char outBuf[512]; int outIndex = 0; int outLeft = sizeof(outBuf) - 1; int t = 0; char timeStamps[MAX_QPATH] = ""; qtime_t ct; char playerName[MAX_QPATH], *mapName = COM_SkipPath(Info_ValueForKey((cl.gameState.stringData + cl.gameState.stringOffsets[CS_SERVERINFO]), "mapname")); Q_strncpyz(playerName, Info_ValueForKey((cl.gameState.stringData + cl.gameState.stringOffsets[CS_PLAYERS+cl.snap.ps.clientNum]), "n"), sizeof(playerName)); Q_CleanStr(playerName, qtrue); Com_RealTime(&ct); format = cl_autoDemoFormat->string; if (!format || !format[0]) { if (!name || !name[0]) { format = "%t"; } else { format = "%n_%t"; } } while (*format && outLeft > 0) { if (haveTag) { char ch = *format++; haveTag = qfalse; switch (ch) { case 'd': //date Com_sprintf( outBuf + outIndex, outLeft, "%d-%02d-%02d-%02d%02d%02d", 1900+ct.tm_year, ct.tm_mon+1,ct.tm_mday, ct.tm_hour, ct.tm_min, ct.tm_sec); outIndex += strlen( outBuf + outIndex ); break; case 'm': //map Com_sprintf( outBuf + outIndex, outLeft, "%s", mapName); outIndex += strlen( outBuf + outIndex ); break; case 'n': //custom demo name Com_sprintf( outBuf + outIndex, outLeft, "%s", name); outIndex += strlen( outBuf + outIndex ); break; case 'p': //current player name Com_sprintf( outBuf + outIndex, outLeft, "%s", playerName); outIndex += strlen( outBuf + outIndex ); break; case 't': //timestamp while (demoAuto.timeStamps[t] && t < MAX_TIMESTAMPS) { int min = demoAuto.timeStamps[t] / 60000; int sec = (demoAuto.timeStamps[t] / 1000) % 60; if (t == 0) { Com_sprintf(timeStamps, sizeof(timeStamps), "%02d%02d", min, sec); } else { Com_sprintf(timeStamps, sizeof(timeStamps), "%s_%02d%02d", timeStamps, min, sec); } t++; } Com_sprintf( outBuf + outIndex, outLeft, "%s", timeStamps); outIndex += strlen( outBuf + outIndex ); break; case '%': outBuf[outIndex++] = '%'; break; default: continue; } outLeft = sizeof(outBuf) - outIndex - 1; continue; } if (*format == '%') { haveTag = qtrue; format++; continue; } outBuf[outIndex++] = *format++; outLeft = sizeof(outBuf) - outIndex - 1; } outBuf[ outIndex ] = 0; return outBuf; }
int Mod_FindExternalVIS (loadedfile_t *brush_fileinfo) { char visfilename[1024]; int fhandle; int len, i, pos; searchpath_t *s_vis; vispatch_t header; char mapname[VISPATCH_MAPNAME_LENGTH+5]; // + ".vis" + EoS fhandle = -1; if (external_vis->value) { // check for a .VIS file strcpy(visfilename, loadmodel->name); COM_StripExtension(visfilename, visfilename); strcat(visfilename, ".vis"); len = COM_OpenFile (visfilename, &fhandle, &s_vis); if (fhandle == -1) // check for a .VIS file with map's directory name (e.g. ID1.VIS) { strcpy(visfilename, "maps/"); strcat(visfilename, COM_SkipPath(brush_fileinfo->path->filename)); strcat(visfilename, ".vis"); len = COM_OpenFile (visfilename, &fhandle, &s_vis); } if (fhandle >= 0) { // check file for size if (len <= 0) { COM_CloseFile(fhandle); fhandle = -1; } } if (fhandle >= 0) { // search map in visfile strncpy(mapname, loadname, VISPATCH_MAPNAME_LENGTH); mapname[VISPATCH_MAPNAME_LENGTH] = 0; strcat(mapname, ".bsp"); pos = 0; while ((i = Sys_FileRead (fhandle, &header, sizeof(struct vispatch_s))) == sizeof(struct vispatch_s)) { header.filelen = LittleLong(header.filelen); pos += i; if (!Q_strncasecmp (header.mapname, mapname, VISPATCH_MAPNAME_LENGTH)) // found { break; } pos += header.filelen; Sys_FileSeek(fhandle, pos); } if (i != sizeof(struct vispatch_s)) { COM_CloseFile(fhandle); fhandle = -1; } } if (fhandle >= 0) { Con_DPrintf("%s for %s loaded from %s\n", visfilename, mapname, s_vis->pack ? s_vis->pack->filename : s_vis->filename); } } return fhandle; }
/* ================= Mod_LoadLighting ================= */ void Mod_LoadLighting (lump_t *l) { int mark; #ifndef RQM_SV_ONLY int i; byte *in, *out/*, d*/; byte *data; char *litfilename; int lit_ver; #endif loadmodel->lightdata = NULL; loadmodel->lightdatadepth = 1; // JDH // if (!l->filelen) // return; // check for a .lit file mark = Hunk_LowMark (); #ifndef RQM_SV_ONLY data = LoadColoredLighting (loadmodel->name, &litfilename); if (data) { if (com_filesize < 8 || strncmp((char *)data, "QLIT", 4)) Con_Printf ("\x02""Corrupt .lit file (%s)...ignoring\n", COM_SkipPath(litfilename)); else if (l->filelen * 3 + 8 != com_filesize) Con_Printf ("\x02""Warning: .lit file (%s) has incorrect size\n", COM_SkipPath(litfilename)); else if ((lit_ver = LittleLong(((int *)data)[1])) != 1) Con_Printf ("\x02""Unknown .lit file version (v%d)\n", lit_ver); else { Con_DPrintf ("Static coloured lighting loaded\n"); loadmodel->lightdata = data + 8; loadmodel->lightdatadepth = 3; in = mod_base + l->fileofs; out = loadmodel->lightdata; for (i=0 ; i<l->filelen ; i++) { int b = max(out[3*i], max(out[3*i+1], out[3*i+2])); if (!b) out[3*i] = out[3*i+1] = out[3*i+2] = in[i]; else { // too bright float r = in[i] / (float)b; out[3*i+0] = (int)(r * out[3*i+0]); out[3*i+1] = (int)(r * out[3*i+1]); out[3*i+2] = (int)(r * out[3*i+2]); } } return; } Hunk_FreeToLowMark (mark); } #endif if (!l->filelen) { //loadmodel->lightdata = NULL; return; } // no .lit found, expand the white lighting data to color #if 0 loadmodel->lightdata = Hunk_AllocName (l->filelen * 3, va("%s_@lightdata", loadmodel->name)); loadmodel->lightdatadepth = 3; // place the file at the end, so it will not be overwritten until the very last write //in = loadmodel->lightdata + l->filelen * 2; in = mod_base + l->fileofs; out = loadmodel->lightdata; //memcpy (in, mod_base + l->fileofs, l->filelen); for (i = 0 ; i < l->filelen ; i++, out += 3) { out[0] = out[1] = out[2] = *in++; } #else loadmodel->lightdata = Hunk_AllocName (l->filelen, "lights"); memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen); #endif }
/* ================== NQD_ParseServerData ================== */ static void NQD_ParseServerData (void) { char *str; int i; int nummodels, numsounds; char mapname[MAX_QPATH]; int cs2; qbool gpl_map; #ifdef GLQUAKE extern qbool r_gpl_map; #endif Com_DPrintf ("Serverdata packet received.\n"); // // wipe the client_state_t struct // CL_ClearState (); // parse protocol version number i = MSG_ReadLong (); if (i != NQ_PROTOCOL_VERSION) Host_Error ("Server returned version %i, not %i", i, NQ_PROTOCOL_VERSION); // parse maxclients nq_maxclients = MSG_ReadByte (); if (nq_maxclients < 1 || nq_maxclients > NQ_MAX_CLIENTS) Host_Error ("Bad maxclients (%u) from server", nq_maxclients); // parse gametype cl.gametype = MSG_ReadByte() ? GAME_DEATHMATCH : GAME_COOP; // parse signon message str = MSG_ReadString (); strlcpy (cl.levelname, str, sizeof(cl.levelname)); // separate the printfs so the server message can have a color Com_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); Com_Printf ("%c%s\n", 2, str); // // first we go through and touch all of the precache data that still // happens to be in the cache, so precaching something else doesn't // needlessly purge it // // precache models for (nummodels=1 ; ; nummodels++) { str = MSG_ReadString (); if (!str[0]) break; if (nummodels == MAX_MODELS) Host_Error ("Server sent too many model precaches"); strlcpy (cl.model_name[nummodels], str, sizeof(cl.model_name[0])); Mod_TouchModel (str); } // precache sounds for (numsounds=1 ; ; numsounds++) { str = MSG_ReadString (); if (!str[0]) break; if (numsounds == MAX_SOUNDS) Host_Error ("Server sent too many sound precaches"); strlcpy (cl.sound_name[numsounds], str, sizeof(cl.sound_name[0])); S_TouchSound (str); } // // now we try to load everything else until a cache allocation fails // cl.clipmodels[1] = CM_LoadMap (cl.model_name[1], true, NULL, &cl.map_checksum2); COM_StripExtension (COM_SkipPath(cl.model_name[1]), mapname); cs2 = Com_TranslateMapChecksum (mapname, cl.map_checksum2); gpl_map = (cl.map_checksum2 != cs2); cl.map_checksum2 = cs2; #ifdef GLQUAKE r_gpl_map = gpl_map; #endif for (i = 1; i < nummodels; i++) { cl.model_precache[i] = Mod_ForName (cl.model_name[i], false, i == 1); if (cl.model_precache[i] == NULL) Host_Error ("Model %s not found", cl.model_name[i]); if (cl.model_name[i][0] == '*') cl.clipmodels[i] = CM_InlineModel(cl.model_name[i]); } for (i=1 ; i<numsounds ; i++) { cl.sound_precache[i] = S_PrecacheSound (cl.sound_name[i]); } // local state if (!cl.model_precache[1]) Host_Error ("NQD_ParseServerData: NULL worldmodel"); COM_StripExtension (COM_SkipPath (cl.model_name[1]), mapname); Cvar_ForceSet (&host_mapname, mapname); CL_ClearParticles (); CL_FindModelNumbers (); R_NewMap (cl.model_precache[1]); TP_NewMap (); Hunk_Check (); // make sure nothing is hurt nq_signon = 0; nq_num_entities = 0; nq_drawpings = false; // unless we have the ProQuake extension cl.servertime_works = true; cl.allow_fbskins = true; r_refdef2.allow_cheats = true; // why not cls.state = ca_onserver; }
void CL_cURL_BeginDownload( const char *baseLocalName, const char *remoteURL ) { char localName[MAX_STRING_CHARS]; Com_sprintf(localName, sizeof(localName), "q3ut4/download/%s", COM_SkipPath(CopyString(baseLocalName))); clc.cURLUsed = qtrue; Com_Printf("URL: %s\n", remoteURL); Com_DPrintf("***** CL_cURL_BeginDownload *****\n" "Localname: %s\n" "RemoteURL: %s\n" "****************************\n", localName, remoteURL); CL_cURL_Cleanup(); Q_strncpyz(clc.downloadURL, remoteURL, sizeof(clc.downloadURL)); Q_strncpyz(clc.downloadName, localName, sizeof(clc.downloadName)); Com_sprintf(clc.downloadTempName, sizeof(clc.downloadTempName), "%s.tmp", localName); // Set so UI gets access to it Cvar_Set("cl_downloadName", localName); Cvar_Set("cl_downloadSize", "0"); Cvar_Set("cl_downloadCount", "0"); Cvar_SetValue("cl_downloadTime", cls.realtime); clc.downloadBlock = 0; // Starting new file clc.downloadCount = 0; clc.downloadCURL = qcurl_easy_init(); if(!clc.downloadCURL) { Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_easy_init() " "failed\n"); return; } clc.download = FS_SV_FOpenFileWrite(clc.downloadTempName); if(!clc.download) { Com_Error(ERR_DROP, "CL_cURL_BeginDownload: failed to open " "%s for writing\n", clc.downloadTempName); return; } qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEDATA, clc.download); if(com_developer->integer) qcurl_easy_setopt(clc.downloadCURL, CURLOPT_VERBOSE, 1); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_URL, clc.downloadURL); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_TRANSFERTEXT, 0); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_REFERER, va("ioQ3://%s", NET_AdrToString(clc.serverAddress))); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_USERAGENT, va("%s %s", Q3_VERSION, qcurl_version())); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEFUNCTION, CL_cURL_CallbackWrite); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_WRITEDATA, &clc.download); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_NOPROGRESS, 0); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSFUNCTION, CL_cURL_CallbackProgress); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_PROGRESSDATA, NULL); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FAILONERROR, 1); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_FOLLOWLOCATION, 1); qcurl_easy_setopt(clc.downloadCURL, CURLOPT_MAXREDIRS, 5); clc.downloadCURLM = qcurl_multi_init(); if(!clc.downloadCURLM) { qcurl_easy_cleanup(clc.downloadCURL); clc.downloadCURL = NULL; Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_multi_init() " "failed\n"); return; } qcurl_multi_add_handle(clc.downloadCURLM, clc.downloadCURL); if(!(clc.sv_allowDownload & DLF_NO_DISCONNECT) && !clc.cURLDisconnected) { CL_AddReliableCommand("disconnect"); CL_WritePacket(); CL_WritePacket(); CL_WritePacket(); clc.cURLDisconnected = qtrue; } }
void FL_StripFileName(filelist_t *fl, filedesc_t *f) { int i; char namebuf[_MAX_FNAME] = {0}; char extbuf[_MAX_EXT] = {0}; char *t; // Don't try to strip this. if (!strcmp(f->name, "..")) { strlcpy (f->display, "/..", sizeof(f->display)); return; } // Common for dir/file, get name without path but with ext strlcpy (namebuf, COM_SkipPath (f->name), sizeof (namebuf)); // File specific. if (!f->is_directory) { // Get extension. snprintf (extbuf, sizeof(extbuf), ".%s", COM_FileExtension (namebuf)); // If the extension is only a . it means we have no extension. if (strlen (extbuf) == 1) { extbuf[0] = '\0'; } // Remove extension from the name. COM_StripExtension(namebuf, namebuf); } if (file_browser_strip_names.value && !f->is_directory) { char *s; for (i=0; i < strlen(namebuf); i++) if (namebuf[i] == '_') namebuf[i] = ' '; // Remove spaces from the beginning s = namebuf; while (*s == ' ') s++; memmove(namebuf, s, strlen(s) + 1); // Remove spaces from the end s = namebuf + strlen(namebuf); while (s > namebuf && *(s-1) == ' ') s--; *s = 0; // Remove few spaces in a row s = namebuf; while (s < namebuf + strlen(namebuf)) { if (*s == ' ') { char *q = s+1; while (*q == ' ') q++; if (q > s+1) memmove(s+1, q, strlen(q)+1); } s++; } if (namebuf[0] == 0) strlcpy (namebuf, "_", sizeof (namebuf)); } // Replace all non-standard characters with '_' for (i=0; i < strlen(namebuf); i++) { if (namebuf[i] < ' ' || namebuf[i] > '~') namebuf[i] = '_'; } f->display[0] = 0; t = f->display; // Add a slash before a dir. if (f->is_directory) *t++ = '/'; // Add the name and extension to the final buffer. for (i=0; i < strlen(namebuf) && (t - f->display) < MAX_PATH; i++) *t++ = namebuf[i]; for (i=0; i < strlen(extbuf) && (t - f->display) < MAX_PATH; i++) *t++ = extbuf[i]; *t = 0; }
/* ================== CL_ParseServerInfo ================== */ void CL_ParseServerInfo (void) { const char *str; int i; int nummodels, numsounds; char model_precache[MAX_MODELS][MAX_QPATH]; char sound_precache[MAX_SOUNDS][MAX_QPATH]; Con_DPrintf ("Serverinfo packet received.\n"); // // wipe the client_state_t struct // CL_ClearState (); // parse protocol version number i = MSG_ReadLong (); //johnfitz -- support multiple protocols if (i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE) { Con_Printf ("\n"); //becuase there's no newline after serverinfo print Host_Error ("Server returned version %i, not %i or %i\n", i, PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE); } cl.protocol = i; //johnfitz // parse maxclients cl.maxclients = MSG_ReadByte (); if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD) { Con_Printf("Bad maxclients (%u) from server\n", cl.maxclients); return; } cl.scores = (scoreboard_t *) Hunk_AllocName (cl.maxclients*sizeof(*cl.scores), "scores"); // parse gametype cl.gametype = MSG_ReadByte (); // parse signon message str = MSG_ReadString (); q_strlcpy (cl.levelname, str, sizeof(cl.levelname)); // seperate the printfs so the server message can have a color Con_Printf ("\n%s\n", Con_Quakebar(40)); //johnfitz Con_Printf ("%c%s\n", 2, str); //johnfitz -- tell user which protocol this is Con_Printf ("Using protocol %i\n", i); // first we go through and touch all of the precache data that still // happens to be in the cache, so precaching something else doesn't // needlessly purge it // precache models memset (cl.model_precache, 0, sizeof(cl.model_precache)); for (nummodels = 1 ; ; nummodels++) { str = MSG_ReadString (); if (!str[0]) break; if (nummodels==MAX_MODELS) { Con_Printf ("Server sent too many model precaches\n"); return; } q_strlcpy (model_precache[nummodels], str, MAX_QPATH); Mod_TouchModel (str); } //johnfitz -- check for excessive models if (nummodels >= 256) Con_Warning ("%i models exceeds standard limit of 256.\n", nummodels); //johnfitz // precache sounds memset (cl.sound_precache, 0, sizeof(cl.sound_precache)); for (numsounds = 1 ; ; numsounds++) { str = MSG_ReadString (); if (!str[0]) break; if (numsounds==MAX_SOUNDS) { Con_Printf ("Server sent too many sound precaches\n"); return; } q_strlcpy (sound_precache[numsounds], str, MAX_QPATH); S_TouchSound (str); } //johnfitz -- check for excessive sounds if (numsounds >= 256) Con_Warning ("%i sounds exceeds standard limit of 256.\n", numsounds); //johnfitz // // now we try to load everything else until a cache allocation fails // // copy the naked name of the map file to the cl structure -- O.S COM_StripExtension (COM_SkipPath(model_precache[1]), cl.mapname, sizeof(cl.mapname)); for (i = 1; i < nummodels; i++) { cl.model_precache[i] = Mod_ForName (model_precache[i], false); if (cl.model_precache[i] == NULL) { Con_Printf("Model %s not found\n", model_precache[i]); return; } CL_KeepaliveMessage (); } S_BeginPrecaching (); for (i = 1; i < numsounds; i++) { cl.sound_precache[i] = S_PrecacheSound (sound_precache[i]); CL_KeepaliveMessage (); } S_EndPrecaching (); // local state cl_entities[0].model = cl.worldmodel = cl.model_precache[1]; R_NewMap (); //johnfitz -- clear out string; we don't consider identical //messages to be duplicates if the map has changed in between con_lastcenterstring[0] = 0; //johnfitz Hunk_Check (); // make sure nothing is hurt noclip_anglehack = false; // noclip is turned off at start warn_about_nehahra_protocol = true; //johnfitz -- warn about nehahra protocol hack once per server connection //johnfitz -- reset developer stats memset(&dev_stats, 0, sizeof(dev_stats)); memset(&dev_peakstats, 0, sizeof(dev_peakstats)); memset(&dev_overflows, 0, sizeof(dev_overflows)); }
/* ==================== CL_PlayDemo_f play [demoname] ==================== */ void CL_PlayDemo_f (void) { char name[256]; qbool try_dem; if (Cmd_Argc() != 2) { Com_Printf ("playdemo <demoname> : plays a demo\n"); return; } // // disconnect from server // Host_EndGame (); // // open the demo file // strlcpy (name, Cmd_Argv(1), sizeof(name)-4); #ifdef _WIN32 if (strlen(name) > 4 && !Q_stricmp(name + strlen(name) - 4, ".qwz")) { PlayQWZDemo (); return; } #endif if (COM_FileExtension(name)[0] == 0) { COM_DefaultExtension (name, ".qwd"); try_dem = true; // if we can't open the .qwd, try .dem also } else try_dem = false; try_again: if (!strncmp(name, "../", 3) || !strncmp(name, "..\\", 3)) cls.demofile = fopen (va("%s/%s", com_basedir, name+3), "rb"); else FS_FOpenFile (name, &cls.demofile); if (!cls.demofile && try_dem) { COM_StripExtension (name, name); strcat (name, ".dem"); try_dem = false; goto try_again; } if (!cls.demofile) { Com_Printf ("ERROR: couldn't open \"%s\"\n", Cmd_Argv(1)); cls.playdemos = 0; return; } Com_Printf ("Playing demo from %s.\n", COM_SkipPath(name)); cls.nqdemoplayback = !Q_stricmp(COM_FileExtension(name), "dem"); if (cls.nqdemoplayback) { NQD_StartPlayback (); } #ifdef MVDPLAY cls.mvdplayback = !Q_stricmp(COM_FileExtension(name), "mvd"); #endif cls.demoplayback = true; cls.state = ca_demostart; Netchan_Setup (NS_CLIENT, &cls.netchan, net_null, 0); cls.demotime = 0; #ifdef MVDPLAY cls.mvd_newtime = cls.mvd_oldtime = 0; cls.mvd_findtarget = true; cls.mvd_lasttype = 0; cls.mvd_lastto = 0; MVD_ClearPredict(); #endif }
/* ================= RE_LoadWorldMap Called directly from cgame ================= */ static void RE_LoadWorldMap_Actual( const char *name ) { int i; dheader_t *header; byte *buffer = NULL; byte *startMarker; if ( tr.worldMapLoaded ) { ri.Error( ERR_DROP, "ERROR: attempted to redundantly load world map\n" ); } // set default sun direction to be used if it isn't // overridden by a shader tr.sunDirection[0] = 0.45f; tr.sunDirection[1] = 0.3f; tr.sunDirection[2] = 0.9f; VectorNormalize( tr.sunDirection ); tr.worldMapLoaded = qtrue; // check for cached disk file from the server first... // extern void *gpvCachedMapDiskImage; extern char gsCachedMapDiskImage[]; if (gpvCachedMapDiskImage) { if (!strcmp(name, gsCachedMapDiskImage)) { // we should always get here, if inside the first IF... // buffer = (byte *)gpvCachedMapDiskImage; } else { // this should never happen (ie renderer loading a different map than the server), but just in case... // assert(0); Z_Free(gpvCachedMapDiskImage); gpvCachedMapDiskImage = NULL; } } if (buffer == NULL) { // still needs loading... // ri.FS_ReadFile( name, (void **)&buffer ); if ( !buffer ) { ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); } } // clear tr.world so if the level fails to load, the next // try will not look at the partially loaded version tr.world = NULL; memset( &s_worldData, 0, sizeof( s_worldData ) ); Q_strncpyz( s_worldData.name, name, sizeof( s_worldData.name ) ); Q_strncpyz( s_worldData.baseName, COM_SkipPath( s_worldData.name ), sizeof( s_worldData.name ) ); COM_StripExtension( s_worldData.baseName, s_worldData.baseName ); startMarker = (unsigned char *) ri.Hunk_Alloc(0, qfalse); c_gridVerts = 0; header = (dheader_t *)buffer; fileBase = (byte *)header; header->version = LittleLong (header->version); if ( header->version != BSP_VERSION ) { ri.Error (ERR_DROP, "RE_LoadWorldMap: %s has wrong version number (%i should be %i)", name, header->version, BSP_VERSION); } // swap all the lumps for (i=0 ; i<sizeof(dheader_t)/4 ; i++) { ((int *)header)[i] = LittleLong ( ((int *)header)[i]); } // load into heap R_LoadShaders( &header->lumps[LUMP_SHADERS] ); R_LoadLightmaps( &header->lumps[LUMP_LIGHTMAPS], name ); R_LoadPlanes (&header->lumps[LUMP_PLANES]); R_LoadFogs( &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] ); R_LoadSurfaces( &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES] ); R_LoadMarksurfaces (&header->lumps[LUMP_LEAFSURFACES]); R_LoadNodesAndLeafs (&header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]); R_LoadSubmodels (&header->lumps[LUMP_MODELS]); R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] ); R_LoadEntities( &header->lumps[LUMP_ENTITIES] ); R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); R_LoadLightGridArray( &header->lumps[LUMP_LIGHTARRAY] ); // only set tr.world now that we know the entire level has loaded properly tr.world = &s_worldData; if (gpvCachedMapDiskImage) { // For the moment, I'm going to keep this disk image around in case we need it to respawn. // No problem for memory, since it'll only be a NZ ptr if we're not low on physical memory // ( ie we've got > 96MB). // // So don't do this... // // Z_Free( gpvCachedMapDiskImage ); // gpvCachedMapDiskImage = NULL; } else { ri.FS_FreeFile( buffer ); } }
/* ================== CL_ParseServerInfo ================== */ static void CL_ParseServerInfo (void) { const char *str; int i; int nummodels, numsounds; char model_precache[MAX_MODELS][MAX_QPATH]; char sound_precache[MAX_SOUNDS][MAX_QPATH]; // rjr edict_t *ent; Con_DPrintf ("Serverinfo packet received.\n"); // // wipe the client_state_t struct // CL_ClearState (); // parse protocol version number cl_protocol = MSG_ReadLong (); switch (cl_protocol) { case PROTOCOL_RAVEN_111: case PROTOCOL_RAVEN_112: case PROTOCOL_UQE_113: Con_Printf ("\nServer using protocol %i\n", cl_protocol); break; default: Con_Printf ("\nServer returned version %i, not %i or %i\n", cl_protocol, PROTOCOL_RAVEN_112, PROTOCOL_UQE_113); return; } // parse maxclients cl.maxclients = MSG_ReadByte (); if (cl.maxclients < 1 || cl.maxclients > MAX_CLIENTS) { Con_Printf("Bad maxclients (%d) from server\n", cl.maxclients); return; } cl.scores = (scoreboard_t *) Hunk_AllocName (cl.maxclients*sizeof(*cl.scores), "scores"); // parse gametype cl.gametype = MSG_ReadByte (); if (cl.gametype == GAME_DEATHMATCH && cl_protocol > PROTOCOL_RAVEN_111) sv_kingofhill = MSG_ReadShort (); // parse signon message str = MSG_ReadString (); q_strlcpy (cl.levelname, str, sizeof(cl.levelname)); // seperate the printfs so the server message can have a color Con_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); Con_Printf ("%c%s\n", 2, str); // // first we go through and touch all of the precache data that still // happens to be in the cache, so precaching something else doesn't // needlessly purge it // // precache models memset (cl.model_precache, 0, sizeof(cl.model_precache)); for (nummodels = 1 ; ; nummodels++) { str = MSG_ReadString (); if (!str[0]) break; if (nummodels == MAX_MODELS) { Con_Printf ("Server sent too many model precaches\n"); return; } q_strlcpy (model_precache[nummodels], str, MAX_QPATH); Mod_TouchModel (str); } // precache sounds memset (cl.sound_precache, 0, sizeof(cl.sound_precache)); for (numsounds = 1 ; ; numsounds++) { str = MSG_ReadString (); if (!str[0]) break; if (numsounds == MAX_SOUNDS) { Con_Printf ("Server sent too many sound precaches\n"); return; } q_strlcpy (sound_precache[numsounds], str, MAX_QPATH); S_TouchSound (str); } // // now we try to load everything else until a cache allocation fails // if (precache.integer) { total_loading_size = nummodels + numsounds; current_loading_size = 1; loading_stage = 2; } // copy the naked name of the map file to the cl structure COM_StripExtension (COM_SkipPath(model_precache[1]), cl.mapname, sizeof(cl.mapname)); //always precache the world!!! cl.model_precache[1] = Mod_ForName (model_precache[1], false); for (i = 2; i < nummodels; i++) { if (precache.integer) { cl.model_precache[i] = Mod_ForName (model_precache[i], false); current_loading_size++; D_ShowLoadingSize(); } else cl.model_precache[i] = (model_t *)Mod_FindName (model_precache[i]); if (cl.model_precache[i] == NULL) { Host_Error("Model %s not found", model_precache[i]); return; } CL_KeepaliveMessage (); } player_models[0] = (model_t *)Mod_FindName ("models/paladin.mdl"); // Note: old demo doesnt have necro and crusader classes. add // a GAME_OLD_DEMO flag check ? player_models[1] = (model_t *)Mod_FindName ("models/crusader.mdl"); player_models[2] = (model_t *)Mod_FindName ("models/necro.mdl"); player_models[3] = (model_t *)Mod_FindName ("models/assassin.mdl"); if (gameflags & GAME_PORTALS) player_models[4] = (model_t *)Mod_FindName ("models/succubus.mdl"); S_BeginPrecaching (); for (i = 1; i < numsounds; i++) { cl.sound_precache[i] = S_PrecacheSound (sound_precache[i]); if (precache.integer) { current_loading_size++; D_ShowLoadingSize(); } CL_KeepaliveMessage (); } S_EndPrecaching (); total_loading_size = 0; loading_stage = 0; // local state cl_entities[0].model = cl.worldmodel = cl.model_precache[1]; R_NewMap (); if (!sv.active) { PR_LoadStrings(); } PR_LoadPuzzleStrings(); // mission pack, objectives strings if (gameflags & GAME_PORTALS) PR_LoadInfoStrings(); Hunk_Check (); // make sure nothing is hurt // we connected to the server, make sure the mouse is going - S.A. menu_disabled_mouse = false; IN_ActivateMouse(); }