MCPcopy Create free account
hub / github.com/demoth/jake2 / SetGamedir

Method SetGamedir

qcommon/src/main/java/jake2/qcommon/filesystem/FS.java:591–632  ·  view source on GitHub ↗

Sets the gamedir and path to a different directory. used when game cvar is changed

(String gameName)

Source from the content-addressed store, hash-verified

589 * used when game cvar is changed
590 */
591 public static void SetGamedir(String gameName) {
592
593 if (gameName.contains("..") || gameName.contains("/") || gameName.contains("\\") || gameName.contains(":")) {
594 Com.Printf("Gamedir should be a single filename, not a path\n");
595 return;
596 }
597
598
599 //
600 // free up any current game dir info
601 //
602 searchPaths.removeIf(path -> {
603 if (path.isGame) {
604 if (path.pack != null)
605 path.pack.closeQuietly();
606 return true;
607 } else return false;
608 });
609
610 //
611 // flush all data, so it will be forced to reload
612 //
613 if ((Globals.dedicated != null) && (Globals.dedicated.value == 0.0f)) {
614 Cbuf.AddText("vid_restart");
615 Cbuf.AddText("snd_restart");
616 }
617
618 fs_gamedir = fs_basedir.string + '/' + gameName;
619
620 if (gameName.equals(Globals.BASEQ2) || gameName.isEmpty()) {
621 Cvar.getInstance().FullSet("gamedir", "", CVAR_SERVERINFO | CVAR_NOSET);
622 Cvar.getInstance().FullSet("game", "", CVAR_LATCH | CVAR_SERVERINFO);
623 } else {
624 Cvar.getInstance().FullSet("gamedir", gameName, CVAR_SERVERINFO | CVAR_NOSET);
625 if (fs_cddir.string != null && fs_cddir.string.length() > 0)
626 AddGameDirectory(fs_cddir.string + '/' + gameName, true);
627
628 AddGameDirectory(fs_basedir.string + '/' + gameName, true);
629 }
630
631 setWriteDir(gameName, true);
632 }
633
634 /*
635 * Link_f

Callers 3

Set2Method · 0.95
updateLatchedVarsMethod · 0.95
InitFilesystemMethod · 0.95

Calls 8

PrintfMethod · 0.95
AddTextMethod · 0.95
getInstanceMethod · 0.95
AddGameDirectoryMethod · 0.95
setWriteDirMethod · 0.95
closeQuietlyMethod · 0.80
FullSetMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected