Show corner.cpp syntax highlighted
/***************************************************************************
corner.cpp - description
-------------------
begin : Thu Aug 29 2002
copyright : (C) 2002 by Brendon Higgins
email : freepop-devel@lists.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <corner.h>
#include <rotation.h>
#include <maptilepos.h>
#include <ClanLib/network.h>
const Corner Corner::NORTH(0);
const Corner Corner::EAST(1);
const Corner Corner::SOUTH(2);
const Corner Corner::WEST(3);
Corner::Corner(const Corner& c) {
id = c.id;
}
Corner::Corner(int n) {
id = n;
}
Corner Corner::operator-() const {
return Corner((id + 2) & 3);
}
bool Corner::operator==(const Corner& x) const {
return id == x.id;
}
Corner& Corner::operator*=(const Rotation& r) {
id = (id + r.getClock()) & 3;
return *this;
}
int Corner::getCornerNum() const {
return id;
}
MapTilePos Corner::getMapTilePos() const {
switch (id) {
case 1: return MapTilePos(1, 0);
case 2: return MapTilePos(1, 1);
case 3: return MapTilePos(0, 1);
default: return MapTilePos(0, 0);
}
}
void Corner::inject(CL_OutputSource& os) const {
os.write_uint8(id);
}
Corner Corner::extract(CL_InputSource& is) {
return Corner(is.read_uint8());
}
See more files for this project here