半透明狐人間のソフトウェア

FakeVRChat.exe

本ページはコードの構文ハイライトにhighlight.jsを使用しています。

GNU/Linuxを始めとしたUnix環境で、VRChatのワールドを「Build and test」出来るようにするプログラムです。

VRChatはWindows向けビルドしかリリースされておらず、動作させるにはProtonが必要です。そのため非Windows環境では VRChatのワールドをオフラインテストすることは出来ませんが、本プログラムをVRChat SDKの設定でVRChatの実行ファイルとして設定することにより、オフラインテストを可能にします。

内部的にはただ単に与えられた引数を調整し、調整された引数を渡して実際のVRChat.exeをProtonで起動するだけです。

使用するには

設定する

使用を開始する前に、あなたの環境に合わせてソースコードを変更して、設定を変更する必要があります。
main関数内の先頭に"Environment settings"とある部分が設定項目です。

設定はstring型の変数に代入する形で記述されており、それぞれの値を変更することで設定を変更出来ます。

compat_data_pathは、Protonのデータが格納されるディレクトリです。通常はSteamフォルダ内のcompatdataディレクトリ内に存在し、中にpfxというフォルダーと、その他Protonの設定データファイル類があります。

compat_client_install_pathはSteamのデータディレクトリです。お持ちの適当なゲームのローカルファイルを閲覧すれば、特定は容易いかと思います。

proton_pathはprotonの実行ファイルです。Pythonスクリプトのようです。Steam上で使用しているProtonのライブラリページを開き、「ローカルファイルを閲覧」を押した時に表示されるディレクトリ内にあります。

vrchat_exe_pathは、VRChatの実行可能ファイル(Windows exe形式)を指定します。こちらもVRChatのライブラリページからローカルファイルを閲覧をすれば特定出来ます。launch.exeではありませ ん。VRChat.exeを指定してください。

設定の例についてはソースコードを参照してください。
ちなみにFlatpakからインストールした場合の例も載せておくと:

	std::string compat_data_path           = "/home/user/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/compatdata/438100";
	std::string compat_client_install_path = "/home/user/.var/app/com.valvesoftware.Steam/.local/share/Steam";
	std::string proton_path                = "/home/user/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/Proton 7.0/proton";
	std::string vrchat_exe_path            = "/home/user/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/VRChat/VRChat.exe";

コンパイルする

コードの変更が終わったら、コンパイルします。
コンパイルして生成される実行可能ファイルの名前は「VRChat.exe」にしてください。Unixでもexeにします。いや、しなくても良いかもしれませんが一応そうしておきます。

g++とclang++でテスト済みです。たぶん、
g++ -O2 -o VRChat.exe VRChat.cpp
でコンパイル出来ると思います。メイクファイルとかそういうのはありません。かんたんかんたん。

VRChat SDKに登録する

コンパイルして実行ファイルが生成されたら、VRChat SDKにVRChat実行ファイルとして生成したファイルを登録します。

VRCSDK Control panelを開き、Settingsタブを開きます。VRChat Client項目で「Edit」を押し、先程生成した実行可能ファイルを登録すれば完了です。Builderタブより「Build and test」を押せば、ワールドがビルドされた後、設定に問題がなければVRChatがテストモードで起動するはずです。

自問自答コーナー

ダウンロード (C++ソースコード, 4.9KiB)

コード内容:
/* FakeVRChat.exe -- The fake \"VRChat.exe\" for running offline test of VRChat World on GNU/Linux.
 * This program starts VRChat using Proton and passes the arguments as is. You can use this program to run offline tests for VRChat worlds on GNU/Linux.
 *
 * To begin using this, modify the "Environment settings" section below. Follow the instructions and adjust the values of each variable to match your environment. The "Environment settings" section is located at the top of the main function.
 * Once you have finished modifying the settings, compile this code to generate an executable file named VRChat.exe (use this name on Unix as well). g++ and clang++ are tested.
 * After VRChat.exe is generated, register it as a VRChat executable file in the Settings panel of VRChat Control Panel.
 */


/* Copyright 2023 半狐 (a.k.a. 半透明狐人間,TlFoxHuman,Translucentfoxhuman)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>



//#define __DEBUG__

int main(int argc,char** argv) {

	/*
	 * Environment settings
	 *
	 * The "compat_data_path" is your Proton data directory. The directory usually has the "pfx" directory.
	 * "compat_client_install_path" is your Steam data directory.
	 * "proton_path" is path to your Proton executable.
	 * "vrchat_exe_path is path to your VRChat executable (not "launch.exe", it must be "VRChat.exe"). You can find it by going to the VRChat page in your Steam Library and selecting "Manage" → "Manage" → "Browse local files".
	 *
	 * Refer to the existing variable values for examples.
	 * */
	std::string compat_data_path           = "/home/user/.local/share/Steam/steamapps/compatdata/438100";
	std::string compat_client_install_path = "/home/user/.local/share/Steam";
	std::string proton_path                = "/home/user/.local/share/Steam/steamapps/common/Proton 7.0/proton";
	std::string vrchat_exe_path            = "/home/user/.local/share/Steam/steamapps/common/VRChat/VRChat.exe";
	//End of Environment settings.

	if (argc <= 1) {
		std::cout << "FakeVRChat.exe -- The fake \"VRChat.exe\" for running offline test of VRChat World on GNU/Linux.\n"
		"Copyright 2023 半狐 (a.k.a. 半透明狐人間,TlFoxHuman,Translucentfoxhuman)\n"
		"This program is provided under the terms of MIT License.\n\n"
		"Usage: Register this program as a VRChat executable file in the Settings panel of VRChat Control Panel." << std::endl;
		return 0;
	}

	std::ostringstream vrccmd;
	vrccmd << "env STEAM_COMPAT_DATA_PATH=\"" << compat_data_path << "\" STEAM_COMPAT_CLIENT_INSTALL_PATH=\"" << compat_client_install_path << "\" \"" << proton_path << "\" run \"" << vrchat_exe_path << "\"";
	//引数の結合
	std::string argstr="";
	for (int i=1;i<argc;i++) {
		argstr+= std::string(argv[i]) + " ";
	}
	#ifdef __DEBUG__
	std::cout << "20-argstr: " << argstr <<std::endl;
	#endif
	int count;
	int fpos = -8;
	while (true) {
		fpos = argstr.find("file:///",fpos+8);
		if (fpos == std::string::npos || count >=argstr.length()) {
			break;
		}
		argstr.insert(fpos+8,"Z:");
		count++;
	}
	#ifdef __DEBUG__
	std::cout << "32-argstr: " << argstr << std::endl;
	#endif
	count = 0;
	fpos = 0;
	while (true) {
		count++;
		fpos = argstr.find("&" ,fpos +3 );
		#ifdef __DEBUG__
		std::cout << "fpos:" << std::to_string(fpos) << std::endl;
		#endif
		if (fpos == std::string::npos || count >=argstr.length()) {
			break;
		}
		argstr.insert(fpos,"\"");
		argstr.insert(fpos+2,"\"");
	}
	#ifdef __DEBUG__
	std::cout << "44-argstr: " << argstr << std::endl;
	#endif
	count=0;
	fpos=0;
	while (true) {
		count++;
		fpos = argstr.find("%2f",fpos+3);
		if (fpos == std::string::npos || count >= argstr.length()) {
			break;
		}
		argstr.replace(fpos,3,"\\\\");
	}
	#ifdef __DEBUG__
	std::cout << "56-argstr: " << argstr << std::endl;
	std::cout << "system:" << vrccmd.str() << " " << argstr << std::endl;
	#endif
	#ifndef __DEBUG__
	system(std::string(vrccmd.str() + " " + argstr).c_str());
	#endif
	return 0;
}

クリエイティブ・コモンズ・ライセンス このページのコンテンツは、ソースコード部分以外は、特に記述がない限り、クリエイティブ・コモンズ 表示 - 継承 4.0 国際 ライセンスの下に提供されています。

このサイトに関するお問い合わせは、こちらまで。

利用規約  半透明狐人間の洞穴