Menu

Deviations from Stanford documentation

Colin Leach

Deviations from Stanford documentation

Moving to a client-server model on a different OS forced a few design changes. It's not hard to work around these, but you need to be aware of them.

Graphics

There is a new function: void SetPort(int port)
Call this BEFORE the first call to InitGraphics() if you don't want port 30004.

SetWindowSize() is best called right after establishing the connection with the first InitGraphics() call. It will work at any time, but will also erase your graphics and change font and color to startup defaults.

Sound

This should be reliable under Windows, but on *nix systems it relies on NAS (Network Audio System, http://radscan.com/nas.html).
A new function bool TestAudio() has been added, which return true if sounds should play on your system, false if you have no chance (as currently configured)

Lexicon

The copies of lexicon.cpp and lexicon.h supplied with the SEE course cause problems on 64-bit systems. Nothing trivial: calling the constructor reliably crashes the program with a segfault. I think (as best I can understand this code) that the 2006 version assumes sizeof(long) is 4 bytes, but gcc on AMD64 versions of Linux uses 8-byte longs. Globally changing "long" to "int" isn't elegant but seems to give working code. I suggest, when doing assignments:
use my modified lexicon.h
ignore lexicon.cpp, as this is compiled into cs106lib.a
if you don't like this change, the old files have been renamed lexicon32.

Maze (and maybe other places)

gcc is apparently less relaxed than Visual Studio about use of the abs(int)
function. When using it (as maze.cpp does in assignment 2) you need to add
#include \<cstdlib>

Boggle

For obscure reasons, EraseOldScore (in gboggle.cpp) fails to work as intended.
This may(?) be something odd going on with z-values of overlaid objects.
Fortunately, SetEraseMode() now works properly for text, so AddScoreForPlayer()
has been changed to use this instead of EraseOldScore().

gcc warnings

Though the ADT size() functions return (signed) int values, string.length() and
similar standard C++ functions return (unsigned) size_t values. This gets
distracting every time you use something like:

    for (int i=0; i<str.size(); i++) {}

If you compile with -Wall (as you should!), it warns about signed vs unsigned
comparisons. In my code I've usually declared i as size_t, but there may be a
few bits of early code using int(str.size()).

gboggle.cpp is a rich source of gcc warnings - see the revised code for comments
on suppressing these.


Related

Wiki: CS106 Libraries
Wiki: Main features