-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Haowei Zhang
authored and
Haowei Zhang
committed
Apr 20, 2014
1 parent
eed1c00
commit 0ca928a
Showing
52 changed files
with
7,929 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef EXCEPTION_H | ||
#define EXCEPTION_H | ||
#include <string> | ||
#include "fwk/Ptr.h" | ||
#include "fwk/PtrInterface.h" | ||
#include <iostream> | ||
using namespace std; | ||
|
||
//Base exception type. | ||
class Exception { | ||
public: | ||
string what() const {return what_;} | ||
virtual ~Exception(){}; | ||
Exception( char const * str ) : what_(str) {} | ||
Exception( string str ) : what_(str) {} | ||
|
||
private: | ||
string what_; | ||
}; | ||
|
||
|
||
class RangeException : public Exception { | ||
public: | ||
RangeException(string info) : Exception(info){}; | ||
~RangeException(){}; | ||
|
||
}; | ||
|
||
|
||
class NameInUseException : public Exception { | ||
public: | ||
NameInUseException(string info) : Exception(info){}; | ||
~NameInUseException(){}; | ||
}; | ||
|
||
class PermissionException : public Exception{ | ||
public: | ||
PermissionException(string info) : Exception(info){}; | ||
~PermissionException(){}; | ||
}; | ||
|
||
class NoImplementationException : public Exception { | ||
public: | ||
NoImplementationException(string info) : Exception(info){}; | ||
~NoImplementationException(){}; | ||
}; | ||
|
||
class AttributeNotSupportedException : public NoImplementationException { | ||
public: | ||
AttributeNotSupportedException(string info) : NoImplementationException(info){}; | ||
~AttributeNotSupportedException(){}; | ||
}; | ||
|
||
class EntityNotFoundException : public Exception { | ||
public: | ||
EntityNotFoundException(string info) : Exception(info) {}; | ||
~EntityNotFoundException(){}; | ||
}; | ||
|
||
|
||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Makefile for the cs244b mazewar assignment | ||
# ------------------------------------------ | ||
# | ||
# Inspired by: | ||
# Ben Werther <[email protected]> Feb 1999 | ||
# Modified by: | ||
# Constantine Sapuntzakis <[email protected]> Apr 1999 | ||
# Modified by: | ||
# Timothy Knight <[email protected]> Mar 2004 | ||
# | ||
# | ||
# To build mazewar, use the command "make"; the executable file | ||
# "mazewar" will be created. | ||
# To clean the directory, use the command "make clean". | ||
# | ||
# This makefile has been tested on epic, elaine, and saga machines using | ||
# GNU Make 3.80, which is at the following path on the Leland machines: | ||
# | ||
# /usr/pubsw/bin/make | ||
# | ||
# A makefile must be submitted with your assignment. It may be based | ||
# on this makefile, or may be re-written by you, but must work with | ||
# the above version of make, and shouldn't assume any environment | ||
# variables to be set to particular values. | ||
# | ||
# Feel free to use other platforms, including Linux, but remember that | ||
# you'll be evaluated during the demo on the Sweet Hall Leland | ||
# machines, so it's recommended that you do your development and | ||
# testing on those machines. | ||
# | ||
|
||
CC = /usr/bin/g++ | ||
CXX = /usr/bin/g++ | ||
RM = /bin/rm | ||
SED = /bin/sed | ||
SH = /bin/sh | ||
|
||
INC_DIRS = -I. -I/usr/openwin/include | ||
FLAGS = -g -Wall $(INC_DIRS) | ||
LIBRARIES = -lXt -lX11 -lnsl -lICE -lSM | ||
LIB_DIRS = -L. -L/usr/X11R6/lib fwk/BaseCollection.o fwk/BaseNotifiee.o fwk/Exception.o | ||
#Removed -lsocket | ||
CFLAGS = $(FLAGS) | ||
CXXFLAGS = $(FLAGS) | ||
|
||
|
||
|
||
|
||
all: mwar | ||
# dummy target points to the real target | ||
dummytarget: mwar | ||
|
||
############################ | ||
# | ||
# Applications | ||
# | ||
|
||
APP_OBJS = toplevel.o display.o init.o winsys.o | ||
APP = mazewar | ||
|
||
$(APP): $(APP_OBJS) | ||
$(CC) -o $(APP) $(APP_OBJS) $(LIB_DIRS) $(LIBRARIES) | ||
|
||
|
||
|
||
############################ | ||
# | ||
# Makefile stuff | ||
# (you probably won't need to change any of this) | ||
# | ||
|
||
.PHONY: dummytarget | ||
|
||
mwar: framework deps | ||
@echo "Building Mazewar..." | ||
@$(MAKE) INCLUDE_DEPS=1 mazewar | ||
|
||
clean: | ||
@echo "Cleaning Mazewar directory..." | ||
$(MAKE) -C fwk/ clean | ||
$(RM) -f *.o *.d *~ mazewar | ||
|
||
framework: | ||
$(MAKE) -C fwk/ | ||
|
||
# Dependency creation | ||
deps: ${APP_OBJS:.o=.d} | ||
@echo "Updating Mazewar dependencies..." | ||
|
||
# Include the dependencies, once we've built them | ||
ifdef INCLUDE_DEPS | ||
include ${APP_OBJS:.o=.d} | ||
endif | ||
|
||
|
||
################################################################# | ||
# | ||
# Dependency stuff | ||
# | ||
|
||
%.cc: %.cpp | ||
cp $< $@ | ||
|
||
%.d: %.cc | ||
@$(SH) -ec '$(CXX) -MM $(CXXFLAGS) $< \ | ||
| $(SED) '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ | ||
[ -s $@ ] || $(RM) -f $@' | ||
|
||
%.d: %.cpp | ||
@$(SH) -ec '$(CXX) -MM $(CXXFLAGS) $< \ | ||
| $(SED) '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ | ||
[ -s $@ ] || $(RM) -f $@' | ||
|
||
%.d: %.c | ||
@$(SH) -ec '$(CC) -MM $(CFLAGS) $< \ | ||
| $(SED) '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ | ||
[ -s $@ ] || $(RM) -f $@' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef __NOMINAL_H__ | ||
#define __NOMINAL_H__ | ||
|
||
template<class UnitType, class RepType> | ||
class Nominal | ||
{ | ||
public: | ||
Nominal(RepType v) : value_(v) {} | ||
|
||
bool operator==(const Nominal<UnitType, RepType>& v) const | ||
{ return value_ == v.value_; } | ||
|
||
bool operator!=(const Nominal<UnitType, RepType>& v) const | ||
{ return value_ != v.value_; } | ||
|
||
const Nominal<UnitType, RepType>& operator=(const Nominal<UnitType, | ||
RepType>& v) | ||
{ value_ = v.value_; return *this; } | ||
|
||
RepType value() const | ||
{ return value_; } | ||
|
||
protected: | ||
RepType value_; | ||
}; | ||
|
||
template<class UnitType, class RepType> | ||
class Ordinal : public Nominal<UnitType, RepType> | ||
{ | ||
public: | ||
Ordinal(RepType v) : Nominal<UnitType, RepType>(v) {} | ||
|
||
bool operator<(const Ordinal<UnitType, RepType>& v) const | ||
{ return Nominal<UnitType, RepType>::value_ < v.value_; } | ||
|
||
bool operator<=(const Ordinal<UnitType, RepType>& v) const | ||
{ return Nominal<UnitType, RepType>::value_ <= v.value_; } | ||
|
||
bool operator>(const Ordinal<UnitType, RepType>& v) const | ||
{ return Nominal<UnitType, RepType>::value_ > v.value_; } | ||
|
||
bool operator>=(const Ordinal<UnitType, RepType>& v) const | ||
{ return Nominal<UnitType, RepType>::value_ >= v.value_; } | ||
|
||
Ordinal<UnitType, RepType> operator+(const Ordinal<UnitType, | ||
RepType>& other) | ||
{ return (Nominal<UnitType, RepType>::value_ + other.value_); } | ||
|
||
Ordinal<UnitType, RepType> operator/(const Ordinal<UnitType, | ||
RepType>& other) | ||
{ return (Nominal<UnitType, RepType>::value_ / other.value_); } | ||
|
||
const Ordinal<UnitType, RepType>& operator++() | ||
{ ++Nominal<UnitType, RepType>::value_; return *this; } | ||
}; | ||
|
||
#endif // __NOMINAL_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#define cup_width 16 | ||
#define cup_height 16 | ||
#define cup_x_hot 1 | ||
#define cup_y_hot 12 | ||
static unsigned char cup_bits[] = { | ||
0x80, 0x00, 0x00, 0x07, 0x00, 0x08, 0xc0, 0x07, 0x20, 0x00, 0xf0, 0x07, | ||
0x48, 0x3c, 0xf8, 0x47, 0x08, 0x58, 0x08, 0x40, 0x08, 0x3c, 0x18, 0x08, | ||
0xf6, 0x37, 0x02, 0x20, 0xfc, 0x17, 0x00, 0x00}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#define dRat_width 16 | ||
#define dRat_height 16 | ||
#define dRat_x_hot 0 | ||
#define dRat_y_hot 9 | ||
static unsigned char dRat_bits[] = { | ||
0x00, 0x00, 0x88, 0x20, 0x45, 0x10, 0x82, 0x00, 0x00, 0x00, 0x00, 0x10, | ||
0x00, 0x20, 0x00, 0x41, 0x20, 0x82, 0xff, 0x87, 0xfa, 0x8f, 0xfc, 0x7f, | ||
0xe8, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#define dRatMask_width 16 | ||
#define dRatMask_height 16 | ||
#define dRatMask_x_hot -1 | ||
#define dRatMask_y_hot -1 | ||
static unsigned char dRatMask_bits[] = { | ||
0x98, 0x60, 0xdd, 0x71, 0xef, 0x38, 0xc7, 0x19, 0x82, 0x00, 0x00, 0x30, | ||
0x00, 0xf1, 0xe0, 0xf3, 0xff, 0xc7, 0xff, 0xcf, 0xff, 0xff, 0xfe, 0xff, | ||
0xfc, 0x7f, 0xe8, 0x0f, 0xc0, 0x07, 0x00, 0x00}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
0x0000, 0x2088, 0x1045, 0x0082, | ||
0x0000, 0x1000, 0x2000, 0x4100, | ||
0x8220, 0x87ff, 0x8ffa, 0x7ffc, | ||
0x0fe8, 0x07c0, 0x0000, 0x0000 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#define icon_width 32 | ||
#define icon_height 32 | ||
static unsigned char icon_bits[] = { | ||
0x0000, 0x0000, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x003c, | ||
0x0004, 0x0000, 0x0000, 0x0006, 0x0008, 0x0000, 0x0000, 0x0005, | ||
0x0010, 0x0000, 0x0080, 0x0004, 0x0020, 0x0000, 0x0040, 0x0004, | ||
0x0040, 0x0000, 0x0020, 0x0004, 0x0040, 0x0000, 0x0010, 0x0004, | ||
0x00c0, 0x00ff, 0x000f, 0x0004, 0x0040, 0x0000, 0x0008, 0x0004, | ||
0x0040, 0x0000, 0x0008, 0x0004, 0x0040, 0x0000, 0x0008, 0x0004, | ||
0x0040, 0x0000, 0x0008, 0x0004, 0x0040, 0x0000, 0x0008, 0x0004, | ||
0x0040, 0x0000, 0x0008, 0x0004, 0x00c0, 0x00ff, 0x000f, 0x0004, | ||
0x0040, 0x0000, 0x0010, 0x0004, 0x0040, 0x0000, 0x0020, 0x0004, | ||
0x0020, 0x00f0, 0x0041, 0x0004, 0x0010, 0x00fa, 0x0083, 0x0004, | ||
0x0008, 0x00ff, 0x0003, 0x0005, 0x0084, 0x00fe, 0x001f, 0x0006, | ||
0x00c2, 0x00ff, 0x0023, 0x003c, 0x0080, 0x0010, 0x0022, 0x0000, | ||
0x0000, 0x0000, 0x0010, 0x0000, 0x0000, 0x00c0, 0x000f, 0x0000, | ||
0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0000, | ||
0x0000, 0x0080, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0000, | ||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 | ||
*/ | ||
0x8888,0x8888,0x8888,0x8888,0x8800,0x0000,0x0000,0x0008, | ||
0x2200,0x0000,0x0000,0x0022,0x2284,0x0000,0x0820,0x0022, | ||
0x8884,0x0000,0x0820,0x0008,0x88CC,0x71F1,0xC827,0x1608, | ||
0x22CC,0x8812,0x2928,0x9922,0x22B4,0x0822,0x2540,0x9022, | ||
0x88B4,0x7843,0xE547,0x9008,0x8884,0x8882,0x0548,0x9008, | ||
0x2284,0x8902,0x2288,0x9022,0x2284,0x79F1,0xC287,0x9022, | ||
0x8800,0x0000,0x0000,0x0008,0x8800,0x0000,0x0000,0x0008, | ||
0x2200,0x0000,0x0000,0x0022,0x2222,0x2222,0x2222,0x2222, | ||
0x8888,0x8888,0x8888,0x8888,0x9FFF,0xFFFF,0xFFFF,0xFFFC, | ||
0x3800,0x0000,0x0000,0x0006,0x3400,0x0000,0x0000,0x0006, | ||
0x9200,0x0000,0x0000,0x0004,0x9100,0x0000,0x0000,0x0004, | ||
0x3080,0x0000,0x0000,0x0006,0x3040,0x0000,0x0000,0x01FE, | ||
0x9020,0x0000,0x0000,0x0304,0x9010,0x0000,0x0000,0x0504, | ||
0x3008,0x0000,0x0000,0x0906,0x3004,0x0000,0x0000,0x1106, | ||
0x9002,0x0000,0x0000,0x2104,0x9001,0x0000,0x0000,0x4104, | ||
0x3000,0x8000,0x0000,0x8106,0x3000,0x4000,0x0001,0x0106, | ||
0x9000,0x3FFF,0xFFFE,0x0104,0x9000,0x2000,0x0002,0x0104, | ||
0x3000,0x2000,0x0002,0x0106,0x3000,0x2000,0x0002,0x0106, | ||
0x9000,0x2000,0x0002,0x0104,0x9000,0x2000,0x0002,0x0104, | ||
0x3000,0x2000,0x0002,0x0106,0x3000,0x2000,0x0002,0x0106, | ||
0x9000,0x2000,0x0002,0x0104,0x9000,0x2000,0x0002,0x0104, | ||
0x3000,0x2000,0x0002,0x0106,0x3000,0x3FFF,0xFFFE,0x0106, | ||
0x9000,0x4000,0x0001,0x0104,0x9000,0x8000,0x0000,0x8104, | ||
0x3001,0x0000,0x0000,0x4106,0x3002,0x0000,0x0000,0x2106, | ||
0x9004,0x0000,0x0000,0x1104,0x9008,0x0001,0xF000,0x0904, | ||
0x3010,0x000B,0xF800,0x0506,0x3020,0x001F,0xF800,0x0306, | ||
0x9040,0x002F,0xFF00,0x01FC,0x9080,0x007F,0xF880,0x0004, | ||
0x3100,0x0021,0x0880,0x0006,0x3200,0x0000,0x0100,0x0006, | ||
0x9400,0x0000,0x7E00,0x0004,0x9800,0x0000,0x8000,0x0004, | ||
0x3000,0x0000,0x4000,0x0006,0x3000,0x0000,0x2000,0x0006, | ||
0x9FFF,0xFFFF,0xFFFF,0xFFFC,0x8888,0x8888,0x8888,0x8888, | ||
0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#define rat_width 16 | ||
#define rat_height 16 | ||
#define rat_x_hot 0 | ||
#define rat_y_hot 6 | ||
static unsigned char rat_bits[] = { | ||
0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0xe8, 0x0f, 0xfc, 0x0f, 0xfa, 0x7f, | ||
0xff, 0x8f, 0x42, 0x08, 0x00, 0x40, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x01, | ||
0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#define ratMask_width 16 | ||
#define ratMask_height 16 | ||
#define ratMask_x_hot -1 | ||
#define ratMask_y_hot -1 | ||
static unsigned char ratMask_bits[] = { | ||
0x00, 0x00, 0xc0, 0x07, 0xe8, 0x0f, 0xfc, 0x1f, 0xfe, 0x7f, 0xff, 0xff, | ||
0xff, 0xff, 0xff, 0xdf, 0xe7, 0xfc, 0x00, 0xff, 0x80, 0x7f, 0x80, 0x03, | ||
0x00, 0x03, 0x80, 0x03, 0x00, 0x01, 0x00, 0x00}; | ||
|
Oops, something went wrong.