Multiple bugfixes #4

Merged
merged 15 commits into from Mar 3, 2012

Projects

None yet

2 participants

@tycho
Contributor
tycho commented Mar 3, 2012
  • replaced resTypeToString array with function, for bounds checking reasons (I encountered game data with type ID '6' which is out-of-bounds)
  • switch to using unsigned 8-bit PCM audio instead of signed, which works around bugs with PulseAudio in most currently available SDL releases (maybe the most recent SDL release contains the fix, I'm not sure). Fixes issue #2
  • LP64 platform compatibility. Long-Pointer 64-bit platforms use a 64-bit 'long', which breaks endian.h (which assumes that 'long' is 32-bit, and typedefs 'uint32' as 'unsigned long'). This causes the game engine to crash at startup.
  • A better fix for LP64 (and more universal compatibility) which switches the 'uint8', 'int8', et. al. to use the types defined in stdint.h (uint8_t, int8_t), which are guaranteed to be the correct sizes, so no preprocessor magic or configure scripts are needed to ensure that the data types are the size we expect.
  • Replace '-O' with '-Os' to optimize for code size. Sort of in the spirit of the original game, and also generally GCC emits better code with this flag.
  • Drop some warning flags which are meaningless for C++ code (-Wstrict-prototypes, -Wimplicit)
  • A bit of whitespace cleanup, particularly in terms of indentation and comma placement on line continuations in resource.cpp.
  • Switched a binary OR to a logical OR (the binary OR made no sense given the context and generated an irritating compiler warning)
  • Clean up an unused variable, initialize an uninitialized variable used in a comparison, etc.
tycho added some commits Mar 2, 2012
@tycho tycho delete junk 'New Text Document.txt' file
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
c5ba542
@tycho tycho Makefile: clean up build flags
Gets rid of these two warnings:

	cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
	cc1plus: warning: command line option ‘-Wimplicit’ is valid for C/ObjC but not for C++ [enabled by default]

And also enables -Os to optimize for space (in the spirit of the original game
engine, really).

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
fcc364b
@tycho tycho resource.cpp: change resTypeToString to a function (for bounds-checki…
…ng purposes)

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
e4b970d
@tycho tycho resource.cpp: fix uninitialized value comparison in Resource::setupPart
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
a9ebfae
@tycho tycho vm.cpp: replace binary OR with logical OR for if statement
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
53eb93e
@tycho tycho video.cpp: remove unused variable 'nullChar'
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
3f3b300
@tycho tycho resource.cpp: fix horrible formatting of debug printouts
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
e4b872f
@tycho tycho endian.h: fix runtime breakage on LP64 platforms
LP64 platforms use a 64-bit integer for longs and pointers. Expecting 'unsigned
long' to be 32-bit in this case totally breaks.

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
1616bb0
@tycho tycho mixer: switch to unsigned 8-bit PCM audio
Work around SDL PulseAudio driver bug.

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
ebda4f2
@tycho tycho eliminate uint8 (et. al.) types in favor of stdint.h type definitions
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
36f8638
@tycho tycho gitignore: ignore 'game' binary and .o, .a, and .d files
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
0b2b819
@tycho
Contributor
tycho commented Mar 3, 2012

Added a commit:

  • Ignore 'game' binary and .o, .a, and .d files.
tycho added some commits Mar 3, 2012
@tycho tycho resource.cpp: fix format string width for resTypeToString element
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
7954c93
@tycho tycho Makefile: disable RTTI and C++ exceptions
We don't need them, and they bloat the code a bit.

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
eb68384
@tycho
Contributor
tycho commented Mar 3, 2012

A couple more minor changes. Sorry to keep amending it. I just keep seeing things that could be improved. ;)

tycho added some commits Mar 3, 2012
@tycho tycho Makefile: add explicit rule for .o file generation
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
c51aaf0
@tycho tycho Makefile: drop redundant -W flags covered by -Wall
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
a8fb787
@fabiensanglard

This means the code will now break on ILP64 (int=64bits) and LP32(int=16bits) (reference:http://www.unix.org/version2/whatsnew/lp64_wp.html). None of the major OS/compilers use either models but is there a way to detect datatype model at compile time and issue a warning for those two platforms ?

Owner
tycho replied Mar 3, 2012
@fabiensanglard

stdint.h is not available in VS2008 but I verified and it is in VS2010 so this change is a Very Good Thing. Amazing work :) !

Owner
tycho replied Mar 3, 2012

stdint.h can actually be implemented in VS2005/VS2008 pretty easily: https://github.com/tycho/cpuid/blob/master/msvc/stdint.h

Owner
tycho replied Mar 3, 2012

Hmm. This commit needs some minor fixes, because I used regular expressions for the replacement:

  • f.writeUint32BE('AWSV');
  • f.writeUint16BE(Serializer::CUR_VER);
  • f.writeUint16BE(0);
  • f.writeUint32_tBE('AWSV');
  • f.writeUint16_tBE(Serializer::CUR_VER);
  • f.writeUint16_tBE(0);

Oops. :)

If you haven't pulled the change in yet, I can rewrite the commit or I can just add an additional commit to fix those goofy bits.

I already pulled it :P ! If you can make an other commit that would be great.

@fabiensanglard fabiensanglard merged commit 735fd69 into fabiensanglard:master Mar 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment