Sets the gamedir and path to a different directory. used when game cvar is changed
(String gameName)
| 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 |
no test coverage detected