summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-03 16:13:12 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-03 16:13:12 +0000
commit182b5231ba13a0a5865a1b7dcb4731c3009d4c57 (patch)
treed0f536d7c3357825efc5f527922c10487517e8bf /src/map.cpp
parentb48b39c87da9fc2c59be533e1dc445cc82c2f323 (diff)
downloadmana-182b5231ba13a0a5865a1b7dcb4731c3009d4c57.tar.gz
mana-182b5231ba13a0a5865a1b7dcb4731c3009d4c57.tar.bz2
mana-182b5231ba13a0a5865a1b7dcb4731c3009d4c57.tar.xz
mana-182b5231ba13a0a5865a1b7dcb4731c3009d4c57.zip
Some indent, comment and const parameter changes.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp96
1 files changed, 45 insertions, 51 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 154f1adc..0687dd53 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -17,6 +17,8 @@
* You should have received a copy of the GNU General Public License
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
*/
#include "main.h"
@@ -33,26 +35,22 @@
MAP tiled_map;
-/** Loads a map file */
bool load_map(char *map_file) {
- PACKFILE *file = pack_fopen(map_file, "rp");
- if(!file) {
- warning(map_file);
- return false;
- }
- pack_fread(&tiled_map, sizeof(MAP), file);
- pack_fclose(file);
- return true;
+ PACKFILE *file = pack_fopen(map_file, "rp");
+ if (!file) {
+ warning(map_file);
+ return false;
+ }
+ pack_fread(&tiled_map, sizeof(MAP), file);
+ pack_fclose(file);
+ return true;
}
-
-/** Set walkability flag for a tile */
void set_walk(short x_c, short y_c, bool walkable) {
- if(walkable==true)tiled_map.tiles[x_c][y_c].data[3] |= 0x0002;
- else tiled_map.tiles[x_c][y_c].data[3] &= 0x00fd;
+ if (walkable == true) tiled_map.tiles[x_c][y_c].data[3] |= 0x0002;
+ else tiled_map.tiles[x_c][y_c].data[3] &= 0x00fd;
}
-/** Tell if a tile is walkable or not */
bool get_walk(short x_c, short y_c) {
bool ret = (tiled_map.tiles[x_c][y_c].data[3] & 0x0002)>0;
if(ret==true) {
@@ -66,57 +64,53 @@ bool get_walk(short x_c, short y_c) {
} else return false;
}
-/** Tell if a tile is walkable or not (0=walkable,1=not walkable) */
unsigned char get_path_walk(unsigned short x, unsigned short y) {
- if(get_walk(x, y))return 0;
- else return 1;
+ if (get_walk(x, y)) return 0;
+ else return 1;
}
-/** Tell if a tile is animated or not */
bool get_anim(short x_c, short y_c, char layer) {
- char temp = tiled_map.tiles[x_c][y_c].flags & 0x00C0;
- temp>>=6;
- if(abs(temp)==layer)return (tiled_map.tiles[x_c][y_c].data[3] & 0x0001)>0;
- else return false;
+ char temp = tiled_map.tiles[x_c][y_c].flags & 0x00C0;
+ temp >>= 6;
+ if(abs(temp)==layer)return (tiled_map.tiles[x_c][y_c].data[3] & 0x0001)>0;
+ else return false;
}
-/** Set tile ID */
void set_tile(short x_c, short y_c, char layer, unsigned short id) {
- if(layer==0) {
- id <<= 6;
+ if (layer == 0) {
+ id <<= 6;
tiled_map.tiles[x_c][y_c].data[0] = HIBYTE(id);
- tiled_map.tiles[x_c][y_c].data[1] &= 0x003f;
+ tiled_map.tiles[x_c][y_c].data[1] &= 0x003f;
tiled_map.tiles[x_c][y_c].data[1] |= LOBYTE(id);
- } else if(layer==1) {
- id <<= 4;
- tiled_map.tiles[x_c][y_c].data[1] &= 0x00c0;
- tiled_map.tiles[x_c][y_c].data[1] |= HIBYTE(id);
- tiled_map.tiles[x_c][y_c].data[2] &= 0x000f;
- tiled_map.tiles[x_c][y_c].data[2] |= LOBYTE(id);
- } else if(layer==2) {
- id <<= 2;
- tiled_map.tiles[x_c][y_c].data[2] &= 0x00f0;
- tiled_map.tiles[x_c][y_c].data[2] |= HIBYTE(id);
- tiled_map.tiles[x_c][y_c].data[3] &= 0x0003;
- tiled_map.tiles[x_c][y_c].data[3] |= LOBYTE(id);
- }
+ } else if (layer == 1) {
+ id <<= 4;
+ tiled_map.tiles[x_c][y_c].data[1] &= 0x00c0;
+ tiled_map.tiles[x_c][y_c].data[1] |= HIBYTE(id);
+ tiled_map.tiles[x_c][y_c].data[2] &= 0x000f;
+ tiled_map.tiles[x_c][y_c].data[2] |= LOBYTE(id);
+ } else if (layer == 2) {
+ id <<= 2;
+ tiled_map.tiles[x_c][y_c].data[2] &= 0x00f0;
+ tiled_map.tiles[x_c][y_c].data[2] |= HIBYTE(id);
+ tiled_map.tiles[x_c][y_c].data[3] &= 0x0003;
+ tiled_map.tiles[x_c][y_c].data[3] |= LOBYTE(id);
+ }
}
-/** Return tile ID */
unsigned short get_tile(short x_c, short y_c, char layer) {
- unsigned short id;
- if(layer==0) {
+ unsigned short id = 0;
+ if (layer == 0) {
id = MAKEWORD(tiled_map.tiles[x_c][y_c].data[1] & 0x00c0,
tiled_map.tiles[x_c][y_c].data[0]);
id >>= 6;
- } else if(layer==1) {
- id = MAKEWORD(tiled_map.tiles[x_c][y_c].data[2] & 0x00f0,
- tiled_map.tiles[x_c][y_c].data[1] & 0x003f);
- id >>= 4;
- } else if(layer==2) {
- id = MAKEWORD(tiled_map.tiles[x_c][y_c].data[3] & 0x00fc,
- tiled_map.tiles[x_c][y_c].data[2] & 0x000f);
- id >>=2;
- }
+ } else if (layer == 1) {
+ id = MAKEWORD(tiled_map.tiles[x_c][y_c].data[2] & 0x00f0,
+ tiled_map.tiles[x_c][y_c].data[1] & 0x003f);
+ id >>= 4;
+ } else if (layer == 2) {
+ id = MAKEWORD(tiled_map.tiles[x_c][y_c].data[3] & 0x00fc,
+ tiled_map.tiles[x_c][y_c].data[2] & 0x000f);
+ id >>= 2;
+ }
return id;
}