このページでは Half-Life2 用サーバプラグインのコンパイル方法を説明します。作成したプラグインは Counter-Strike:Source (CS:S), Half-Life2 Deathmatch (HL2DM) で利用できます。
"Plugin"
{
"file" "../cstrike/addons/serverplugin_empty"
}
ファイル構成としては、以下のようになっていれば OK です。
cstrike/addons/serverplugin_empty.dll cstrike/addons/serverplugin_empty.vdfサーバを起動して、コンソールから plugin_print でプラグインがロードされたか確認。
] plugin_print Loaded plugins: --------------------- 0: "Emtpy-Plugin, Valve" ---------------------デキタ!
[guwashi@localhost ~]$ uname -a Linux localhost.localdomain 2.6.9-1.667 #1 Tue Nov 2 14:41:25 EST 2004 i686 i686 i386 GNU/Linux [guwashi@localhost ~]$ rpm -q gcc gcc-3.4.2-6.fc3 [guwashi@localhost ~]$ rpm -q glibc glibc-2.3.3-74ちなみに筆者は Windows XP に VMware Workstation 5 をインストールして、ゲスト OS として FC3 をインストールして作業しています。
[guwashi@localhost ~]$ cd [guwashi@localhost ~]$ pwd /home/guwashi [guwashi@localhost ~]$ mkdir -p src [guwashi@localhost ~]$ cd src [guwashi@localhost src]$ wget http://www.apache.org/dist/xml/xerces-c/xerces-c-src_2_6_0.tar.gz [guwashi@localhost src]$ tar xfz xerces-c-src_2_6_0.tar.gz [guwashi@localhost src]$ export XERCESCROOT=/home/guwashi/src/xerces-c-src_2_6_0 [guwashi@localhost src]$ cd xerces-c-src_2_6_0/src/xercesc [guwashi@localhost xercesc]$ autoconf [guwashi@localhost xercesc]$ ./runConfigure -plinux -cgcc -xg++ [guwashi@localhost xercesc]$ gmake
[guwashi@localhost ~]$ cd [guwashi@localhost ~]$ pwd /home/guwashi [guwashi@localhost ~]$ mkdir -p srcds_1 [guwashi@localhost ~]$ cd srcds_1/ [guwashi@localhost srcds_1]$ wget http://www.steampowered.com/download/hldsupdatetool.bin [guwashi@localhost srcds_1]$ chmod +x hldsupdatetool.binhldsupdatetool.bin の実行には uncompress というコマンドが必要となります。が、FC3 を普通にインストールすると uncompress がないようですので gunzip のシンボリックリンクを作っておきます。
[guwashi@localhost srcds_1]$ su - [root@localhost ~]# ln -s /usr/bin/gunzip /usr/local/bin/uncompress [root@localhost ~]# exitで、以下を実行。
[guwashi@localhost srcds_1]$ ./hldsupdatetool.bin [guwashi@localhost srcds_1]$ ./steam -command update -game "Counter-Strike Source" -dir .
[guwashi@localhost ~]$ cd ~/tmp/SourceMod/linux_sdk [guwashi@localhost linux_sdk]$ cp -p Makefile.vcpm Makefile.vcpm.org [guwashi@localhost linux_sdk]$ vi Makefile.vcpm [guwashi@localhost linux_sdk]$ diff -u Makefile.vcpm.org Makefile.vcpm --- Makefile.vcpm.org 2005-06-11 00:26:39.000000000 +0900 +++ Makefile.vcpm 2005-06-17 23:55:30.000000000 +0900 @@ -19,7 +19,7 @@ #CFLAGS+= $(DEBUG) INCLUDEDIRS=-I$(PUBLIC_SRC_DIR) -I$(XERCES_INC_DIR) -I$(UTIL_COMMON_SRC_DIR) -I$(TIER1_PUBLIC_SRC_DIR) -LDFLAGS_VC=-lm -ldl -L$(XERCES_LIB_DIR) -lxerces-c $(GAME_DIR)/bin/tier0_i486.so $(GAME_DIR)/bin/vstdlib_i486.so +LDFLAGS_VC=-lm -ldl -L$(XERCES_LIB_DIR) -lxerces-c tier0_i486.so vstdlib_i486.so DO_CC=$(CPLUS) $(INCLUDEDIRS) -w $(CFLAGS) -DARCH=$(ARCH) -o $@ -c $<Makefile.serverplugin_empty を作って、こんなかんじに編集。
[guwashi@localhost linux_sdk]$ cp -p Makefile Makefile.org [guwashi@localhost linux_sdk]$ cp -p Makefile Makefile.serverplugin_empty [guwashi@localhost linux_sdk]$ vi Makefile.serverplugin_empty [guwashi@localhost linux_sdk]$ diff -u Makefile.org Makefile.serverplugin_empty --- Makefile.org 2005-06-11 00:26:39.000000000 +0900 +++ Makefile.serverplugin_empty 2005-07-02 17:36:45.961971192 +0900 @@ -8,32 +8,31 @@ ############################################################################# # the name of the mod binary (_i486.so is appended to the end) -NAME=server +NAME=serverplugin_empty # the location of the vcproj that builds the mod -MOD_PROJ=../dlls/hl_sdk.vcproj +MOD_PROJ=../utils/serverplugin_sample/serverplugin_empty.vcproj # the name of the mod configuration (typically_ ) -MOD_CONFIG=hl_ReleaseSDKWin32 +MOD_CONFIG=$(NAME)_ReleaseWin32 # the directory the base binaries (tier0_i486.so, etc) are located -#GAME_DIR=../../ -GAME_DIR=~/valve/hl2bin/ +GAME_DIR=. # compiler options (gcc 3.4.1 or above is required) -CC=/usr/local/bin/gcc -CPLUS=/usr/local/bin/g++ -CLINK=/usr/local/bin/gcc -CPP_LIB="/usr/local/lib/libstdc++.a /usr/local/lib/libgcc_eh.a" +CC=/usr/bin/gcc +CPLUS=/usr/bin/g++ +CLINK=/usr/bin/gcc +CPP_LIB="/usr/lib/gcc/i386-redhat-linux/3.4.2/libstdc++.a /usr/lib/gcc/i386-redhat-linux/3.4.2/libgcc_eh.a" # put any compiler flags you want passed here USER_CFLAGS= # link flags for your mod, make sure to include any special libraries here -LDFLAGS="-lm -ldl $(GAME_DIR)/bin/tier0_i486.so $(GAME_DIR)/bin/vstdlib_i486.so" +LDFLAGS="-lm -ldl tier0_i486.so vstdlib_i486.so" # XERCES 2.6.0 or above ( http://xml.apache.org/xerces-c/ ) is used by the vcproj to makefile converter # it must be installed before being able to run this makefile -XERCES_INC_DIR=/home/alfred/tmp/xerces-c-src_2_6_0/include -XERCES_LIB_DIR=/home/alfred/tmp/xerces-c-src_2_6_0/lib +XERCES_INC_DIR=/home/guwashi/src/xerces-c-src_2_6_0/include +XERCES_LIB_DIR=/home/guwashi/src/xerces-c-src_2_6_0/lib # if you have xerces installed already you should be able to use the two lines below #XERCES_INC_DIR=/usr/include #XERCES_LIB_DIR=/usr/lib
[guwashi@localhost linux_sdk]$ ln -sf ~/srcds_1/bin/tier0_i486.so . [guwashi@localhost linux_sdk]$ ln -sf ~/srcds_1/bin/vstdlib_i486.so .
[guwashi@localhost linux_sdk]$ export LD_LIBRARY_PATH=~/src/xerces-c-src_2_6_0/lib:.make
[guwashi@localhost linux_sdk]$ make -f Makefile.serverplugin_empty modデキタ!
[guwashi@localhost linux_sdk]$ ls -l serverplugin_empty_i486.so -rwxrwxr-x 1 guwashi guwashi 163128 Jul 2 18:06 serverplugin_empty_i486.so
[guwashi@localhost linux_sdk]$ cp -p serverplugin_empty_i486.so ~/srcds_1/cstrike/addons"addons" フォルダに "serverplugin_empty.vdf" というファイルを作って以下のように書く(HL2DM の場合は "cstrike" の部分を "hl2mp" にする)。
"Plugin"
{
"file" "../cstrike/addons/serverplugin_empty"
}
サーバを起動。
[guwashi@localhost linux_sdk]$ cd ~/srcds_1 [guwashi@localhost srcds_1]$ ./srcds_run -console -game cstrike +map de_dust2 +maxplayers 12 -autoupdate +ip xxx.xxx.xxx.xxxplugin_print でプラグインがロードされたか確認。
plugin_print Loaded plugins: --------------------- 0: "Emtpy-Plugin, Valve" ---------------------デキタ!
Guwashi