Skip to content

Commit

Permalink
work around -conclearlog not working
Browse files Browse the repository at this point in the history
  • Loading branch information
p2r3 committed Dec 1, 2024
1 parent 2dbce8d commit 187bd55
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tools/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ bool startPortal2 (const std::vector<std::string> extraArgs) {
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE; // Hide the window for the detached process

std::wstring args = L"-applaunch 620 -tempcontent -condebug -conclearlog";
std::wstring args = L"-applaunch 620 -tempcontent -condebug";
if (SPPLICE_NETCON_PORT != -1) {
args += L" -netconport " + std::to_wstring(SPPLICE_NETCON_PORT);
}
Expand Down Expand Up @@ -590,11 +590,17 @@ void ToolsInstall::uninstall () {
if (GAME_DIR.empty() || SPPLICE_INSTALL_STATE == 0) return;

// Remove the tempcontent directory link
const std::filesystem::path tempcontentPath = std::filesystem::path(GAME_DIR) / "portal2_tempcontent";
const std::filesystem::path tempcontentPath = GAME_DIR / "portal2_tempcontent";
if (isDirectoryLink(tempcontentPath)) unlinkDirectory(tempcontentPath);

// Remove the actual package directory containing all package files
const std::filesystem::path tmpPackageDirectory = CACHE_DIR / "tempcontent";
std::filesystem::remove_all(tmpPackageDirectory);

// HACK: The Windows console workaround creates a logfile that needs to be cleaned up
#ifdef TARGET_WINDOWS
std::filesystem::path logPath = (GAME_DIR / "portal2") / "console.log";
if (std::filesystem::exists(logPath)) std::filesystem::remove(logPath);
#endif

}
15 changes: 15 additions & 0 deletions tools/js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ struct customJS {
struct game {
static duk_ret_t connect (duk_context *ctx) {

// HACK: The TCP console interface is buggy for an unknown reason, this is a Windows-only workaround
#ifdef TARGET_WINDOWS
std::filesystem::path logPath = (GAME_DIR / "portal2") / "console.log";
if (std::filesystem::exists(logPath)) {
consoleLogOffset = std::filesystem::file_size(logPath);
}
duk_push_number(ctx, 1);
return 1;
#endif

int sockfd = ToolsNetCon::attemptConnection();
duk_push_number(ctx, sockfd);
return 1;
Expand All @@ -165,6 +175,11 @@ struct customJS {
int sockfd = duk_to_int(ctx, 0);
if (sockfd < 0) return duk_type_error(ctx, "game.disconnect: Invalid socket provided");

// HACK: The TCP console interface is buggy for an unknown reason, this is a Windows-only workaround
#ifdef TARGET_WINDOWS
return 0;
#endif

ToolsNetCon::disconnect(sockfd);
return 0;

Expand Down

0 comments on commit 187bd55

Please sign in to comment.