Show maptile.cpp syntax highlighted
/***************************************************************************
maptile.cpp - description
-------------------
begin : Mon Aug 5 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 <maptile.h>
#include <corner.h>
#include <maptilepos.h>
#include <ClanLib/network.h>
MapTile::MapTile(): z(0) {
}
MapTile::MapTile(const MapTile& t): s(t.s), z(t.z) {
}
MapTile::MapTile(unsigned int zz, const Slope& ss): s(ss), z(zz) {
}
MapTile::~MapTile() {
}
bool MapTile::isAtSeaLevel() const {
return z == 0;
}
bool MapTile::isSea(const MapTilePos& p) const {
return z == 0 && s.getZ(p) == 0.0f;
}
int MapTile::getZ() const {
return z;
}
float MapTile::getZ(const MapTilePos& p) const {
return s.getZ(p) + z;
}
bool MapTile::isFlat() const {
return s.isFlat();
}
Slope MapTile::getSlope() const {
return s;
}
void MapTile::raiseCorner(const Corner& c) {
z += s.raiseCorner(c);
}
void MapTile::lowerCorner(const Corner& c) {
z += s.lowerCorner(c);
}
MapTile& MapTile::operator*=(const Rotation& r) {
s *= r;
return *this;
}
unsigned int MapTile::getCornerPos(const Corner& c) const {
return z + s.getCornerPos(c);
}
bool MapTile::isCornerAtSeaLevel(const Corner& c) const {
return isAtSeaLevel() && s.getCornerPos(c) == 0;
}
unsigned short MapTile::type() const {
return 0;
}
void MapTile::inject(CL_OutputSource& os) const {
os.write_uint16(z);
s.inject(os);
}
void MapTile::extract(CL_InputSource& is) {
z = is.read_uint16();
s.extract(is);
}
See more files for this project here