Changeset - r8409:2e7aa818987b
[Not reviewed]
master
7 6 0
rubidium - 16 years ago 2008-01-24 18:47:05
rubidium@openttd.org
(svn r11979) -Codechange: drop MSVC 2003 support because MSVC 2003 is broken in such a manner that it triggers an internal compiler error without any clue what of the code is wrong. Even trying to bisect the problem does not give a single line of code that causes the trouble.
13 files changed with 53 insertions and 5136 deletions:
0 comments (0 inline, 0 general)
docs/Readme_Windows_MSVC.txt
Show inline comments
 
Compiling OpenTTD using Microsoft Visual C++
 
January 2, 2007
 
--------------------------------------------
 
PLEASE READ THE ENTIRE DOCUMENT BEFORE DOING ANY ACTUAL CHANGES!!
 

	
 

	
 
SUPPORTED MSVC COMPILERS
 
------------------------
 
OpenTTD includes projects for MSVC 2003.NET and MSVC 2005.NET. Both will
 
OpenTTD includes projects for MSVC 2005.NET and MSVC 2008.NET. Both will
 
compile out of the box, providing you have the required libraries/headers;
 
which ones, see below. There is no support for VS6, you are therefore
 
strongly encouraged to either upgrade to MSVC 2005 Express (free) or use GCC.
 
MSVC 2002 probably works as well, but it has not been tested.
 
which ones, see below. There is no support for VS6 or MSVC 2002, or
 
MSVC 2003.NET. You are therefore strongly encouraged to either upgrade to
 
MSVC 2005 Express (free) or use GCC.
 

	
 

	
 
1) REQUIRED FILES
 
-----------------
 
You might already have some of the files already installed, so check before
 
downloading; mostly because the DirectX SDK and Platform SDK are about
 
500MB each.
 
Download the following files:
 

	
 
	* openttd-useful.zip (http://sf.net/project/showfiles.php?group_id=103924&package_id=114307)
 
	* DirectX 8.1 SDK (http://neuron.tuke.sk/~mizanin/eng/Dx81sdk-include-lib.rar) (or alternatively the latest DirectX SDK from Microsoft)
 
	* MS Windows Platform SDK (http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en)
 
@@ -65,65 +65,51 @@ 2.2) CUSTOM DIRECTORIES
 
If you have put the above include and/or library files into custom folders,
 
MSVC will not find them by default. You need to add these paths to VC through:
 

	
 
Tools > Options > Projects and Solutions > VC++ Directories > show directories for
 

	
 
	* Include files: Add the DirectX/Platform SDK include dir you've created
 
	* Library files: Add the path to the SDK custom lib dir
 

	
 
NOTE: make sure that the directory for the DirectX SDK is the first one in the
 
list, above all others, otherwise compilation will most likely fail!!
 

	
 

	
 
2.3) DEBUGGING - WORKING DIRECTORY (MSVC 2003 ONLY!)
 
----------------------------------------------------
 
The very first time you check out and compile OpenTTD with Visual Studio 2003, running
 
the binary will complain about missing files. You need to go into and change a setting
 

	
 
OpenTTD > Project > Properties > Configuration (All Configurations) > ...
 
 Configuration Properties > Debugging >
 

	
 
	* Working Directory: ..\bin
 

	
 
VS 2005 works out of the box because Microsoft allowed a user to supply a humanly-
 
readable defaults file (openttd_vs80.vcproj.user), whereas 2003 is braindead.
 

	
 

	
 
3) TTD GRAPHICS FILES
 
---------------------
 
Copy the following files from Transport Tycoon Deluxe to the bin/data folder
 

	
 
	* sample.cat
 
	* trg1r.grf
 
	* trgcr.grf
 
	* trghr.grf
 
	* trgir.grf
 
	* trgtr.grf
 

	
 

	
 
4) COMPILING
 
------------
 
Open trunk/openttd[_vs80].sln
 
Open trunk/openttd_vs[89]0.sln
 
Set the build mode to 'Release' in
 
Build > Configuration manager > Active solution configuration > select "Release"
 
Compile...
 

	
 
If everything works well the binary should be in trunk/objs/[Win32]/Release/openttd.exe
 
If everything works well the binary should be in trunk/objs/Win[32|64]/Release/openttd.exe
 

	
 

	
 
5) EDITING, CHANGING SOURCE CODE
 
--------------------------------
 
Set the build mode (back to) 'Debug'
 
Change the startup project to openttd by right-clicking the 'openttd' project
 
in the Solution Explorer and selecting 'Set as Startup Project'. The 'openttd'
 
project should now show up bold instead of 'strgen'.
 

	
 

	
 
6) PROBLEMS?
 
------------
 
If compilation fails, double-check that you are using the latest SVN (!)
 
source. If it still doesn't work, check in on IRC (irc://irc.oftc.net/openttd),
 
to ask about reasons; or just wait. The problem will most likely solve itself
 
within a few days as the problem is noticed and fixed.
 

	
 
An up-to-date version of this README can be found on the wiki:
 
http://wiki.openttd.org/index.php/MicrosoftVisualCExpress
 
\ No newline at end of file
 
http://wiki.openttd.org/index.php/MicrosoftVisualCExpress
projects/generate
Show inline comments
 
@@ -16,31 +16,24 @@ then
 
fi
 

	
 
# openttd_vs90.sln    is for MSVC 2008
 
# openttd_vs90.vcproj is for MSVC 2008
 
# langs_vs90.vcproj   is for MSVC 2008
 
# strgen_vs90.vcproj  is for MSVC 2008
 

	
 
# openttd_vs80.sln    is for MSVC 2005
 
# openttd_vs80.vcproj is for MSVC 2005
 
# langs_vs80.vcproj   is for MSVC 2005
 
# strgen_vs80.vcproj  is for MSVC 2005
 

	
 
# openttd.sln         is for MSVC 2003
 
# openttd.vcproj      is for MSVC 2003
 
# langs.vcproj        is for MSVC 2003
 
# strgen.vcproj       is for MSVC 2003
 

	
 
# openttd.tgt         is for WatCom
 

	
 

	
 

	
 
# First, collect the list of Windows files
 
sdl_config="1"
 
png_config="1"
 
os="MSVC"
 
enable_dedicated="0"
 
with_cocoa="0"
 
enable_directmusic="1"
 
with_threads="1"
 
file_prefix="..\\\\src\\\\"
 

	
 
@@ -101,107 +94,94 @@ load_main_data() {
 
				gsub("	", "", $0);
 
				gsub("^#", "", $0);
 
				gsub("^ ", "", $0);
 

	
 
				if (first_time != 0) {
 
					print "		</Filter>";
 
				} else {
 
					first_time = 1;
 
				}
 

	
 
				print "		<Filter";
 
				print "			Name=\\""$0"\\"";
 
				print "			Filter=\\"\\">";
 
				print "			>";
 
			}
 

	
 
			next;
 
		}
 
		/^$/ { next }
 
		{
 
			if (deep == skip) {
 
				gsub("	", "", $0);
 
				gsub("/", "\\\\", $0);
 
				print "			<File";
 
				print "				RelativePath=\\".\\\\'$file_prefix'"$0"\\">";
 
				print "				RelativePath=\\".\\\\'$file_prefix'"$0"\\"";
 
				print "				>";
 
				print "			</File>";
 
			}
 
		}
 
		END { print "		</Filter>"; }
 
	'`"
 

	
 
	eval "$2=\"\$RES\""
 
}
 

	
 
load_lang_data() {
 
	RES=""
 
	for i in `ls $1`
 
	do
 
		i=`basename $i | sed s/.txt$//g`
 
		RES="$RES
 
		<File
 
			RelativePath=\"..\\src\\lang\\"$i".txt\">
 
			RelativePath=\"..\\src\\lang\\"$i".txt\"
 
			>
 
			<FileConfiguration
 
				Name=\"Debug|Win32\">
 
				Name=\"Debug|Win32\"
 
				>
 
				<Tool
 
					Name=\"VCCustomBuildTool\"
 
					Description=\"Generating "$i" language file\"
 
					CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang &quot;\$(InputPath)&quot;&#x0D;&#x0A;\"
 
					AdditionalDependencies=\"\"
 
					Outputs=\"..\\bin\\lang\\"$i".lng\"/>
 
					Outputs=\"..\\bin\\lang\\"$i".lng\"
 
				/>
 
			</FileConfiguration>
 
		</File>"
 
	done
 

	
 
	eval "$2=\"\$RES\""
 
}
 

	
 
generate() {
 
	echo "Generating $2..."
 
	# Everything above the !!FILES!! marker
 
	cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
 
		/^$/ { next }
 
		/!!FILES!!/ { stop = 1; }
 
		{
 
			if (stop == 0) { print $0 }
 
		}
 
	' > "$ROOT_DIR/projects/$2"
 

	
 
	# The files-list
 
	echo "$1" | awk -v type="$3" '
 
		/&#x0D;&#x0A;/ {
 
			if (type == "msvc2003") gsub("&#x0D;&#x0A;", "\n", $0);
 
		}
 
		/Filter="">/ {
 
			if (type == "msvc2005") gsub("Filter=\"\">", ">", $0);
 
		}
 
		/"\/>/ {
 
			if (type == "msvc2005") gsub("/>", "\n" substr($0, 1, index($0, $1) - 2) "/>", $0);
 
		}
 
		/">/ {
 
			if (type == "msvc2005") gsub(">", "\n" substr($0, 1, index($0, $1) - 1) ">", $0);
 
		}
 
		{ print $0 }
 
	' >> "$ROOT_DIR/projects/$2"
 
	echo "$1" >> "$ROOT_DIR/projects/$2"
 

	
 
	# Everything below the !!FILES!! marker
 
	cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
 
		BEGIN { stop = 1; }
 
		/^$/ { next }
 
		/!!FILES!!/ { stop = 2; }
 
		{
 
			if (stop == 0) { print $0 }
 
			if (stop == 2) { stop = 0 }
 
		}
 
	' >> "$ROOT_DIR/projects/$2"
 
}
 

	
 
safety_check "$ROOT_DIR/source.list"
 

	
 
load_main_data "$ROOT_DIR/source.list" openttd
 
load_lang_data "$ROOT_DIR/src/lang/*.txt" lang
 

	
 
generate "$openttd" "openttd.vcproj"      "msvc2003"
 
generate "$openttd" "openttd_vs80.vcproj" "msvc2005"
 
generate "$openttd" "openttd_vs90.vcproj" "msvc2005"
 
generate "$lang" "langs.vcproj"           "msvc2003"
 
generate "$lang" "langs_vs80.vcproj"      "msvc2005"
 
generate "$lang" "langs_vs90.vcproj"      "msvc2005"
 
generate "$openttd" "openttd_vs80.vcproj"
 
generate "$openttd" "openttd_vs90.vcproj"
 
generate "$lang" "langs_vs80.vcproj"
 
generate "$lang" "langs_vs90.vcproj"
projects/langs.vcproj
Show inline comments
 
deleted file
projects/langs.vcproj.in
Show inline comments
 
deleted file
projects/openttd.sln
Show inline comments
 
deleted file
projects/openttd.tgt
Show inline comments
 
deleted file
projects/openttd.vcproj
Show inline comments
 
deleted file
projects/openttd.vcproj.in
Show inline comments
 
deleted file
projects/strgen.vcproj
Show inline comments
 
deleted file
src/debug.cpp
Show inline comments
 
@@ -50,68 +50,52 @@ struct DebugLevel {
 
	DEBUG_LEVEL(oldloader),
 
	DEBUG_LEVEL(ntp),
 
	DEBUG_LEVEL(npf),
 
	DEBUG_LEVEL(yapf),
 
	DEBUG_LEVEL(freetype),
 
	DEBUG_LEVEL(sl),
 
	DEBUG_LEVEL(station),
 
	};
 
#undef DEBUG_LEVEL
 

	
 
#if !defined(NO_DEBUG_MESSAGES)
 

	
 
/** Functionized DEBUG macro for compilers that don't support
 
 * variadic macros (__VA_ARGS__) such as...yes MSVC2003 and lower */
 
#if defined(NO_VARARG_MACRO)
 
void CDECL DEBUG(int name, int level, ...)
 
{
 
	va_list va;
 
	const char *dbg;
 
	const DebugLevel *dl = &debug_level[name];
 

	
 
	if (level != 0 && *dl->level < level) return;
 
	dbg = dl->name;
 
	va_start(va, level);
 
#else
 
void CDECL debug(const char *dbg, ...)
 
{
 
	va_list va;
 
	va_start(va, dbg);
 
#endif /* NO_VARARG_MACRO */
 
	{
 
		const char *s;
 
		char buf[1024];
 
	const char *s;
 
	char buf[1024];
 

	
 
		s = va_arg(va, const char*);
 
		vsnprintf(buf, lengthof(buf), s, va);
 
		va_end(va);
 
	s = va_arg(va, const char*);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	va_end(va);
 
#if defined(ENABLE_NETWORK)
 
		if (_debug_socket != INVALID_SOCKET) {
 
			char buf2[lengthof(buf) + 32];
 
	if (_debug_socket != INVALID_SOCKET) {
 
		char buf2[lengthof(buf) + 32];
 

	
 
			snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf);
 
			send(_debug_socket, buf2, strlen(buf2), 0);
 
		} else
 
		snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf);
 
		send(_debug_socket, buf2, strlen(buf2), 0);
 
	} else
 
#endif /* ENABLE_NETWORK */
 
		{
 
	{
 
#if defined(WINCE)
 
			/* We need to do OTTD2FS twice, but as it uses a static buffer, we need to store one temporary */
 
			TCHAR tbuf[512];
 
			_sntprintf(tbuf, sizeof(tbuf), _T("%s"), OTTD2FS(dbg));
 
			NKDbgPrintfW(_T("dbg: [%s] %s\n"), tbuf, OTTD2FS(buf));
 
		/* We need to do OTTD2FS twice, but as it uses a static buffer, we need to store one temporary */
 
		TCHAR tbuf[512];
 
		_sntprintf(tbuf, sizeof(tbuf), _T("%s"), OTTD2FS(dbg));
 
		NKDbgPrintfW(_T("dbg: [%s] %s\n"), tbuf, OTTD2FS(buf));
 
#else
 
			fprintf(stderr, "dbg: [%s] %s\n", dbg, buf);
 
		fprintf(stderr, "dbg: [%s] %s\n", dbg, buf);
 
#endif
 
			IConsoleDebug(dbg, buf);
 
		}
 
		IConsoleDebug(dbg, buf);
 
	}
 
}
 
#endif /* NO_DEBUG_MESSAGES */
 

	
 
void SetDebugString(const char *s)
 
{
 
	int v;
 
	char *end;
 
	const char *t;
 

	
 
	/* global debugging level? */
 
	if (*s >= '0' && *s <= '9') {
src/debug.h
Show inline comments
 
@@ -10,86 +10,54 @@
 
 * maximum debugging level should be 10 if really deep, deep
 
 * debugging is needed.
 
 * (there is room for exceptions, but you have to have a good cause):
 
 * 0   - errors or severe warnings
 
 * 1   - other non-fatal, non-severe warnings
 
 * 2   - crude progress indicator of functionality
 
 * 3   - important debugging messages (function entry)
 
 * 4   - debugging messages (crude loop status, etc.)
 
 * 5   - detailed debugging information
 
 * 6.. - extremely detailed spamming
 
 */
 

	
 
/* Of course MSVC 2003 and lower has no support for variadic macros
 
 * so we need to work around this... *sigh* */
 
#if defined(_MSC_VER) && (_MSC_VER < 1400)
 
	#define NO_VARARG_MACRO
 
#endif
 

	
 
#if defined(NO_VARARG_MACRO)
 
	enum DebugLevelType {
 
		ai,
 
		driver,
 
		grf,
 
		map,
 
		misc,
 
		ms,
 
		net,
 
		sprite,
 
		oldloader,
 
		ntp,
 
		npf,
 
		yapf,
 
		freetype,
 
		sl,
 
		station,
 
	};
 
#endif /* NO_VARARG_MACRO */
 

	
 
#ifdef NO_DEBUG_MESSAGES
 
	#if defined(NO_VARARG_MACRO)
 
		static inline void DEBUG(int name, int level, ...) {}
 
	#elif defined(__GNUC__) && (__GNUC__ < 3)
 
	#if defined(__GNUC__) && (__GNUC__ < 3)
 
		#define DEBUG(name, level, args...)
 
	#else
 
		#define DEBUG(name, level, ...)
 
	#endif
 
#else /* NO_DEBUG_MESSAGES */
 
	#if defined(NO_VARARG_MACRO)
 
		void CDECL DEBUG(int name, int level, ...);
 
	#elif defined(__GNUC__) && (__GNUC__ < 3)
 
	#if defined(__GNUC__) && (__GNUC__ < 3)
 
		#define DEBUG(name, level, args...) if ((level == 0) || ( _debug_ ## name ## _level >= level)) debug(#name, args)
 
	#else
 
		#define DEBUG(name, level, ...) if (level == 0 || _debug_ ## name ## _level >= level) debug(#name, __VA_ARGS__)
 
	#endif
 

	
 
	extern int _debug_ai_level;
 
	extern int _debug_driver_level;
 
	extern int _debug_grf_level;
 
	extern int _debug_map_level;
 
	extern int _debug_misc_level;
 
	extern int _debug_ms_level;
 
	extern int _debug_net_level;
 
	extern int _debug_sprite_level;
 
	extern int _debug_oldloader_level;
 
	extern int _debug_ntp_level;
 
	extern int _debug_npf_level;
 
	extern int _debug_yapf_level;
 
	extern int _debug_freetype_level;
 
	extern int _debug_sl_level;
 
	extern int _debug_station_level;
 

	
 
	#if !defined(NO_VARARG_MACRO)
 
		void CDECL debug(const char *dbg, ...);
 
	#endif /* NO_VARARG_MACRO */
 
	void CDECL debug(const char *dbg, ...);
 
#endif /* NO_DEBUG_MESSAGES */
 

	
 
void SetDebugString(const char *s);
 
const char *GetDebugString();
 

	
 
/* MSVCRT of course has to have a different syntax for long long *sigh* */
 
#if defined(_MSC_VER) || defined(__MINGW32__)
 
	#define OTTD_PRINTF64 "I64"
 
#else
 
	#define OTTD_PRINTF64 "ll"
 
#endif
 

	
src/graph_gui.cpp
Show inline comments
 
@@ -34,25 +34,25 @@ enum {
 
	GRAPH_AXIS_LINE_COLOUR  = 215,
 

	
 
	GRAPH_X_POSITION_BEGINNING  = 44,  ///< Start the graph 44 pixels from gw->left
 
	GRAPH_X_POSITION_SEPARATION = 22,  ///< There are 22 pixels between each X value
 

	
 
	GRAPH_NUM_LINES_Y = 9, ///< How many horizontal lines to draw.
 
	/* 9 is convenient as that means the distance between them is the height of the graph / 8,
 
	 * which is the same
 
	 * as height >> 3. */
 
};
 

	
 
/* Apparently these don't play well with enums. */
 
static const OverflowSafeInt64 INVALID_DATAPOINT = INT64_MAX; // Value used for a datapoint that shouldn't be drawn.
 
static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn.
 
static const uint INVALID_DATAPOINT_POS = UINT_MAX;  // Used to determine if the previous point was drawn.
 

	
 
struct GraphDrawer {
 
	uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed.
 
	byte num_dataset;
 
	byte num_on_x_axis;
 
	bool has_negative_values;
 
	byte num_vert_lines;
 

	
 
	/* The starting month and year that values are plotted against. If month is
 
	 * 0xFF, use x_values_start and x_values_increment below instead. */
 
	byte month;
src/stdafx.h
Show inline comments
 
@@ -147,37 +147,35 @@
 
	#define _WIN32_WINNT 0x0500       // Windows 2000
 
	#define _WIN32_WINDOWS 0x400      // Windows 95
 
	#if !defined(WINCE)
 
		#define WINVER 0x0400     // Windows NT 4.0 / Windows 95
 
	#endif
 
	#define _WIN32_IE_ 0x0401         // 4.01 (win98 and NT4SP5+)
 

	
 
	#define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
 
	#pragma warning(disable: 4244)  // 'conversion' conversion from 'type1' to 'type2', possible loss of data
 
	#pragma warning(disable: 4761)  // integral size mismatch in argument : conversion supplied
 
	#pragma warning(disable: 4200)  // nonstandard extension used : zero-sized array in struct/union
 

	
 
	#if (_MSC_VER >= 1400)                   // MSVC 2005 safety checks
 
		#pragma warning(disable: 4996)   // 'strdup' was declared deprecated
 
		#define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
 
		#pragma warning(disable: 6308)   // code analyzer: 'realloc' might return null pointer: assigning null pointer to 't_ptr', which is passed as an argument to 'realloc', will cause the original memory block to be leaked
 
		#pragma warning(disable: 6011)   // code analyzer: Dereferencing NULL pointer 'pfGetAddrInfo': Lines: 995, 996, 998, 999, 1001
 
		#pragma warning(disable: 6326)   // code analyzer: potential comparison of a constant with another constant
 
		#pragma warning(disable: 6031)   // code analyzer: Return value ignored: 'ReadFile'
 
		#pragma warning(disable: 6255)   // code analyzer: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
 
		#pragma warning(disable: 6246)   // code analyzer: Local declaration of 'statspec' hides declaration of the same name in outer scope. For additional information, see previous declaration at ...
 
	#else /* _MSC_VER >= 1400  ( <1400 for MSVC2003) */
 
		#pragma warning(disable: 4288)   // nonstandard extension used : 'y' : loop control variable declared in the for-loop is used outside the for-loop scope; it conflicts with the declaration in the outer scope
 
		#pragma warning(disable: 4292)   // compiler limit : terminating debug information emission for enum 'StringIdEnum' with member 'STR_801D_COAL_CAR'
 
	#endif /* _MSC_VER >= 1400 */
 
	#if (_MSC_VER < 1400)                   // MSVC 2005 safety checks
 
		#error "Only MSVC 2005 or higher are supported. MSVC 2003 and earlier are not!. Upgrade your compiler."
 
	#endif /* (_MSC_VER < 1400) */
 
	#pragma warning(disable: 4996)   // 'strdup' was declared deprecated
 
	#define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
 
	#pragma warning(disable: 6308)   // code analyzer: 'realloc' might return null pointer: assigning null pointer to 't_ptr', which is passed as an argument to 'realloc', will cause the original memory block to be leaked
 
	#pragma warning(disable: 6011)   // code analyzer: Dereferencing NULL pointer 'pfGetAddrInfo': Lines: 995, 996, 998, 999, 1001
 
	#pragma warning(disable: 6326)   // code analyzer: potential comparison of a constant with another constant
 
	#pragma warning(disable: 6031)   // code analyzer: Return value ignored: 'ReadFile'
 
	#pragma warning(disable: 6255)   // code analyzer: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
 
	#pragma warning(disable: 6246)   // code analyzer: Local declaration of 'statspec' hides declaration of the same name in outer scope. For additional information, see previous declaration at ...
 

	
 
	#include <malloc.h> // alloca()
 
	#define NORETURN __declspec(noreturn)
 
	#define FORCEINLINE __forceinline
 
	#define inline _inline
 

	
 
	#if !defined(WINCE)
 
		#define CDECL _cdecl
 
	#endif
 

	
 
	int CDECL snprintf(char *str, size_t size, const char *format, ...);
 
	#if (_MSC_VER < 1400) || defined(WINCE)
0 comments (0 inline, 0 general)