summary refs log tree commit diff stats
path: root/src/map.cpp
blob: cb1ce7251259a35310bc23c35ab49e47e62f8d5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "map.h"
#include "mapview.h"

Map::Map(char* filename)
{
  FILE* f = fopen(filename, "r");
  m_mapdata = (char*) malloc(MAP_WIDTH*(MAP_HEIGHT-1)*sizeof(char));
  
  for (int i=0; i<MAP_HEIGHT-1; i++)
  {
    fread(m_mapdata + i*MAP_WIDTH, sizeof(char), MAP_WIDTH, f);
    fgetc(f);
  }
  
  m_title = (char*) calloc(41, sizeof(char));
  fgets(m_title, 41, f);
  
  fclose(f);
}

Map::~Map()
{
  free(m_mapdata);
  free(m_title);
}

const char* Map::mapdata()
{
  return m_mapdata;
}

const char* Map::title()
{
  return m_title;
}

Map* Map::getLeftMap()
{
  return m_leftMap;
}

Map* Map::getRightMap()
{
  return m_rightMap;
}

void Map::setLeftMap(Map* m)
{
  m_leftMap = m;
}

void Map::setRightMap(Map* m)
{
  m_rightMap = m;
}