In Memoriam: Tai'lahr
OpenUru.org, along with the rest of the Mystonline community, is mourning the loss of Tai'lahr on October 16th, 2019.
Rest in Peace, friend.
Build the client with MSVC 2008
Introduction
This document provides steps to build the CWE client with MSVC 2008 SP1 Express, with minimal changes from the current CWE-OU source as of 05-Dec-2018 [1].
This is an attempt to enhance the usability of the CWE-ou source tree by utilizing a freely available compiler and some updated libraries.
Please note that the client created using these instructions has not undergone extensive testing.
These instructions need the project files from Pull request #45 on the CWE bitbucket.
Items needed to compile
- Microsoft Visual Studio 2008 SP1 Express
- DirectX 9.0c SDK (August 2007)
- OpenSSL 1.0.2q
- libogg-1.3.2
- libvorbis-1.3.6
- OpenAL v1.1 SDK
- Ageia PhysX 2.6.4 Core SDK
- libspeex 1.2.0
Notes
- Libogg 1.3.2 was used because xiph removed the VS2008 projects from 1.3.3.
- The client has physics bugs (cannot step off the Kadish elevator, and such) when compiled with PhysX 2.6.4 (the only available version). If you can obtain it, PhysX 2.6.0 is the version Cyan used, and clients compiled with it do not seem to have these physics bugs.
- You must use a 2.6.x version of PhysX for CWE, because the cooked mesh format was changed in PhysX 2.7.x and later.
- Some minor source changes are required in order to compile with VS 2008 SP1 Express version. Those will be documented below.
- All libraries are compiled with "Whole Program Optimization" turned off.
- All release version libraries are compiled as "Multi-threaded DLL (/MD)"
- All debug version libraries are compiled as "Multi-threaded Debug DLL (/MDd)"
- It is understood that the specified DirectX SDK (Aug 2007) has expired messages for one of it's components. The client does not use that particular component, and we are using that DirectX SDK version because it is the newest available SDK that does not require source changes to use. The earlier October 2005 version is no longer available from Microsoft.
- Crypto keys are located in "CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\NucleusLib\pnNetBase". Edit the *.hpp files with a text editor to replace Cyan's keys with your own server's keys. Always clean your solution and rebuild when you change crypto keys, to make sure they are updated.
- Server hostnames, IP addresses, and ports are located in the following files:
The status URL:
"CWE\MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/winmain.cpp"
"CWE\MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plUruLauncher/Main.cpp"
The auth/gatekeeper address
"CWE\MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/NucleusLib/pnNetBase/Private/pnNbSrvs.cpp"
The default client port
"CWE\MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/NucleusLib/pnNetBase/pnNbConstant.h"
Build preparation steps
- Obtain CWE-OU source
- Install Visual Studio 2008 SP1 Express
- Copy the include and lib directories from the SDK installed with VS2008 SP1 Express to "\CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\PlatformSDK". The directory where the SDK resides will most likely be "\Program Files\Microsoft SDKs\Windows\v6.0A". As the SDK is in our path, this step is probably not necessary but we will do it for consistency.
Directory structure in the CWE tree will look like this:StaticSDKs Win32 PlatformSDK include lib
- Install the OpenAL SDK and copy the include and lib directories to "\CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\OpenAL 1.1 with EFX SDK"
Directory structure in the CWE tree will look like this:StaticSDKs win32 OpenAL 1.1 with EFX SDK include libs
- Install the DirectX 9.0c SDK (Say "OK" to the expired xaudio2 messages - we do not use that) and copy it to "\CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\DX9.0c".
Directory structure in the CWE tree will look like this:StaticSDKs Win32 DX9.0c include Lib
- Copy PhysX subdirectories from "\Program Files\AGEIA Technologies\AGEIA PhysX SDK\v2.6.4\SDKs" and "\Program Files (x86)\AGEIA Technologies\AGEIA PhysX SDK\v2.6.4\Bin" to ""\CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\PhysX
Directory structure in the CWE tree will look like this:StaticSDKs Win32 PhysX Bin Cooking Docs Foundation Framework lib ...
- Build Ogg and Vorbis
- Create a directory and extract Ogg and Vorbis archives to it.
oggvorbis libogg-1.3.2 libvorbis-1.3.6
- Change directory to "\libvorbis-1.3.6\win32\vs2008" and edit the libogg.vsprops file. Change the "LIBOGG_VERSION" value to match your version of Ogg (1.3.2 in this document).
- Open "\libogg-1.3.2\win32\VS2008\libogg_static.sln" in the Visual Studio IDE.
- Click on configuration drop-down on the upper left and select "Release"
- Right click on project in the solution explorer and select properties.
- Select "Configuration Properties -> General" in the left pane, and then select "Whole Program Optimization" in the right pane, and select "No Whole Program Optimization" from the drop-down.
- Select "C/C++ -> Code Generation" in the left pane, and select "Runtime Library" and verify it is set to "Multi-threaded DLL (/MD)"
- Click on "Apply"
- Click on configuration drop-down on the upper left of the properties page and select "Debug"
- Select "Configuration Properties -> General" in the left pane, and then select "Whole Program Optimization" in the right pane, and select "No Whole Program Optimization" from the drop-down.
- Select "C/C++ -> Code Generation" in the left pane, and select "Runtime Library" and verify it is set to "Multi-threaded Debug DLL (/MDd)"
- Click "Apply" and then "OK".
- On the IDE toolbar, select "Release" from the drop down. then right click on the project in the solution explorer and select "Build".
- On the IDE toolbar, select "Debug" from the drop down. then right click on the project in the solution explorer and select "Build".
- Open "\libvorbis-1.3.6\win32\VS2008\vorbis_static.sln" in the Visual Studio IDE.
- Repeat steps "d" through "n" for libvorbis_static and libvorbisfile.
- Copy Ogg and Vorbis files to CWE
- Copy the ogg and vorbis include directories into "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\oggvorbis\include". It is okay to let it overwrite.
- Copy the "libogg-1.3.2\win32\VS2008\Win32\Release" and "Debug" directories into "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\oggvorbis\lib"
- Copy the "libvorbis-1.3.6\win32\VS2008\Win32\Release" and "Debug" directories to "CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\oggvorbis\lib" Directory structure in the CWE tree will look like this:
- Build Speex 1.2.0
- Create a directory and extract the Speex 1.2.0 archive into it.
- Unfortunately, the speex-1.2.0 release is missing the "fftwrap.c" file. Obtain the missing file from the Speex github repository and copy it into "speex-1.2.0\libspeex" directory (the directory that also has "fftwrap.h" in it). fftwrap.c
- Open "\speex-1.2.0\win32\VS2008\libspeex.sln" in the VS2008 IDE. Ignore "project missing" errors - we are only building libspeex.
- Click on configuration drop-down on the upper left and select "Release_RTL_dll"
- Right click on the "libspeex" project in the solution explorer and select properties.
- Select "Configuration Properties -> General" in the left pane, and then select "Whole Program Optimization" in the right pane, and select "No Whole Program Optimization" from the drop-down.
- Select "C/C++ -> Code Generation" in the left pane, and select "Runtime Library" and verify it is set to "Multi-threaded DLL (/MD)"
- Click on "Apply"
- Click on configuration drop-down on the upper left of the properties page and select "Debug_RTL_dll"
- Select "Configuration Properties -> General" in the left pane, and then select "Whole Program Optimization" in the right pane, and select "No Whole Program Optimization" from the drop-down.
- Select "C/C++ -> Code Generation" in the left pane, and select "Runtime Library" and verify it is set to "Multi-threaded Debug DLL (/MDd)"
- Click "Apply" and then "OK".
- On the IDE toolbar, select "Release_RTL_dll" from the drop down. then right click on the "libspeex" project in the solution explorer and select "Build".
- On the IDE toolbar, select "Debug_RTL_dll" from the drop down. then right click on project in the solution explorer and select "Build".
- Copy the "Speex-1.2.0" you just compiled into "MOULOpenSourceClientPlugin\StaticSDKs\Win32".
StaticSDKs win32 speex-1.2.0 doc include libspeex ...
- Compile and install OpenSSL (see Build OpenSSL with MS Visual C++). As this is security software, it is best (in my opinion) to compile it yourself from source. You can choose either static or dynamic linking.
Note: If you link it dynamically, it will cause the Uru client to require the OpenSSL DLLs to be present in the client directory or in the system path.
Copy the installed stuff to "\CWE\MOULOpenSourceClientPlugin\StaticSDKs\Win32\OpenSSL" (created by "make install" - you do not want your development tree here).
Directory structure in the CWE tree will look like this:StaticSDKs Win32 OpenSSL bin include openssl lib
- Open "Visual Studio 2008 Command Prompt" and change to the "\CWE\MOULOpenSourceClientPlugin\StaticSDKs\XPlatform\jpeg-8c-rgba directory." Copy makefile.vc to makefile.nmake, and jconfig.vc to jconfig.h and then run nmake nodebug=1 -f makefile.nmake. This will build the library in non-debug mode. If you use a debug library, the linker will complain when we link the client executable.
- Install zlib and libpng
- Download zlib127.zip (or a newer version) from http://www.zlib.net/, extract the zlib-1.2.7 folder it contains and move/rename it to MOULOpenSourceClientPlugin/StaticSDKs/XPlatform/zlib.
- Download lpng1511.zip (or a newer version) from http://libpng.org/pub/png/libpng.html, extract the lpng1511 folder it contains and move/rename it to MOULOpenSourceClientPlugin/StaticSDKs/XPlatform/png.
- Open png/projects/visualc71/libpng.sln in the Visual Studio 2008 IDE.
- Right-click on the “libpng” project in the Solution Explorer and choose Properties.
- Select configuration “LIB Debug” in the popup menu at the top.
- Select Configuration Properties > C/C++ > Code Generation on the left.
- Change the Runtime Library line to “Multi-threaded Debug DLL (/MDd)”. (This step avoids a warning in the final Plasma build. As far as I understand, leaving it out is harmless, but better do it to be sure.)
- Choose the “LIB Release” configuration and set Runtime Library to “Multi-threaded DLL (/MD)”.
- Repeat steps 4 to 8 for the other two projects “pngtest” and “zlib”.
- Select “LIB Debug” from the Solution Configurations popup menu in the toolbar, then Build > Build Solution.
- Select the “LIB Release” configuration and build the solution.
- Make a new folder png/lib and move png/projects/visualc71/Win32_LIB_Debug/libpngd.lib as well as png/projects/visualc71/Win32_LIB_Release/libpng.lib into it.
- Make a new folder zlib/lib and move png/projects/visualc71/Win32_LIB_Debug/ZLib/zlibd.lib as well as png/projects/visualc71/Win32_LIB_Release/ZLib/zlib.lib into it.
StaticSDKs win32 oggvorbis include ogg vorbis lib Debug Release
Required source code changes
- plFileUtils.cpp file located in directory "\CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\PubUtilLib\plFile"
Remove the "#include <errno.h>" line from the "#if HS_BUILD_FOR_UNIX" section and move it under "#include <sys/stat.h>"
Before
#include <time.h> #include <sys/types.h> #include <sys/stat.h> #if HS_BUILD_FOR_WIN32 #include <direct.h> #include <io.h> #endif #if HS_BUILD_FOR_UNIX #include <unistd.h> #include <errno.h> #include <utime.h> #endif
After
#include <time.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #if HS_BUILD_FOR_WIN32 #include <direct.h> #include <io.h> #endif #if HS_BUILD_FOR_UNIX #include <unistd.h> #include <utime.h> #endif
- hsWindows.h file located in directory "\CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\CoreLib"
Change the _MSC_VER >=1600 to 1500.
Before
#ifndef __AFX_H__ // MFC apps won't let us include windows from here. =( #if defined(_MSC_VER) && _MSC_VER >= 1600 #define _WIN32_WINNT 0x0501 #else #define _WIN32_WINNT 0x0400 #endif
After
#ifndef __AFX_H__ // MFC apps won't let us include windows from here. =( #if defined(_MSC_VER) && _MSC_VER >= 1500 #define _WIN32_WINNT 0x0501 #else #define _WIN32_WINNT 0x0400 #endif
- plClient.rc file located in "\CWE\MOULOpenSourceClientPlugin\Plasma20\Sources\Plasma\Apps\plClient\res\"
We do not have MFC with VS2008 SP1 Express, so we need to replace the first reference to afxres.h. The client portion of CWE does not use MFC (I believe the MAX plugin does), so we can make this replacement.
Before
// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h"
After
// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // //#include "afxres.h" #include <windows.h> #define IDC_STATIC (-1)
- plUruLauncher.rc file located in "\CWE\MOULOpenSourceClientPlugin\Plasma20\Apps\plUruLauncher.rc"
This is the same change we just made in the previous file.
Before
// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h"
After
// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // //#include "afxres.h" #include <windows.h> #define IDC_STATIC (-1)
Build the client
Now that the prep is done, you can actually build the client.
- Open the "CWE\MOULOpenSourceClientPlugin\Plasma20\MSVC8Projects\Plasma\Apps\AllClient\AllClient-ou.sln" in the VS2008 IDE.
- Select the type of build you want from the dropdown on the IDE toolbar.
- Release
- Release_Internal
- Debug
- Debug_Internal
- Right click on the "AllClient" project and select "Build".
Completed builds are copied into the "CWE\MOULOpenSourceClientPlugin\Plasma20\test" directory.
Note: You *must* make sure your client is using the same versions of the PhysX DLLs that you built with. They are not compatible from version to version.
If, after building the client, you require the server prep tools (plFileSecure, plFileEncrypt, plPythonPak), right click on those specific projects and click "Build".
The compiled files will be copied into the "CWE\MOULOpenSourceClientPlugin\Plasma20\test" directory.
DirectX notes
It is possible to use the latest DirectX 9.0c SDK (June 2010) with some more source changes. The client compiles and runs with these changes, but it has not been extensively tested. This basic documentation is here in case Microsoft decides to pull the link for the DX Aug 2007 SDK.
Change "#include <dxerr9.h>" to "#include <dxerr9.h>"
Change "DXGetErrorString9" to "DXGetErrorString"
Change "#include <dxerr9.h>" to "#include <dxerr.h>"
Remove the "#include <dmusici.h>" line
Change "#include <dxerr9.h>" to "#include <dxerr.h>"
Remove linker reference to "dplayx.lib"
Change linker reference "dxerr9.lib" to "dxerr.lib"
Remove linker reference to "dplayx.lib"
Change linker reference "dxerr9.lib" to "dxerr.lib"