Skip to content

Commit

Permalink
Improve terrain texture selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Jan 22, 2019
1 parent 54ea1e5 commit 54b02ed
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 437 deletions.
7 changes: 5 additions & 2 deletions CIO/CFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ bobMAP* CFile::open_wld()
CHECK_READ(libendian::read(myMap->name, 20, fp));
CHECK_READ(libendian::le_read_us(&myMap->width_old, fp));
CHECK_READ(libendian::le_read_us(&myMap->height_old, fp));
CHECK_READ(libendian::read(&myMap->type, 1, fp));
uint8_t mapType;
CHECK_READ(libendian::read(&mapType, 1, fp));
myMap->type = MapType(mapType);
CHECK_READ(libendian::read(&myMap->player, 1, fp));
CHECK_READ(libendian::read(myMap->author, 20, fp));
for(unsigned short& i : myMap->HQx)
Expand Down Expand Up @@ -807,7 +809,8 @@ bool CFile::save_wld(void* data)
// old height
libendian::le_write_us(myMap->height_old, fp);
// type
libendian::write(&myMap->type, 1, fp);
auto mapType = uint8_t(myMap->type);
libendian::write(&mapType, 1, fp);
// players
libendian::write(&myMap->player, 1, fp);
// author
Expand Down
11 changes: 6 additions & 5 deletions CMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ CMap::~CMap()
destructMap();
}

void CMap::constructMap(const std::string& filename, int width, int height, int type, int texture, int border, int border_texture)
void CMap::constructMap(const std::string& filename, int width, int height, MapType type, TriangleTerrainType texture, int border,
int border_texture)
{
map = nullptr;
Surf_Map = nullptr;
Expand Down Expand Up @@ -211,7 +212,7 @@ void CMap::destructMap()
delete map;
}

bobMAP* CMap::generateMap(int width, int height, int type, int texture, int border, int border_texture)
bobMAP* CMap::generateMap(int width, int height, MapType type, TriangleTerrainType texture, int border, int border_texture)
{
bobMAP* myMap = new bobMAP();

Expand Down Expand Up @@ -899,7 +900,7 @@ void CMap::setKeyboardData(const SDL_KeyboardEvent& key)
callback::EditorAnimalMenu(MAP_QUIT);
callback::EditorPlayerMenu(MAP_QUIT);

map->type = 0;
map->type = MAP_GREENLAND;
unloadMapPics();
loadMapPics();

Expand All @@ -920,7 +921,7 @@ void CMap::setKeyboardData(const SDL_KeyboardEvent& key)
callback::EditorAnimalMenu(MAP_QUIT);
callback::EditorPlayerMenu(MAP_QUIT);

map->type = 1;
map->type = MAP_WASTELAND;
unloadMapPics();
loadMapPics();

Expand All @@ -941,7 +942,7 @@ void CMap::setKeyboardData(const SDL_KeyboardEvent& key)
callback::EditorAnimalMenu(MAP_QUIT);
callback::EditorPlayerMenu(MAP_QUIT);

map->type = 2;
map->type = MAP_WINTERLAND;
unloadMapPics();
loadMapPics();

Expand Down
6 changes: 3 additions & 3 deletions CMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class CMap
public:
CMap(const std::string& filename);
~CMap();
void constructMap(const std::string& filename, int width = 32, int height = 32, int type = 0, int texture = TRIANGLE_TEXTURE_MEADOW1,
int border = 4, int border_texture = TRIANGLE_TEXTURE_WATER);
void constructMap(const std::string& filename, int width = 32, int height = 32, MapType type = MAP_GREENLAND,
TriangleTerrainType texture = TRIANGLE_TEXTURE_MEADOW1, int border = 4, int border_texture = TRIANGLE_TEXTURE_WATER);
void destructMap();
bobMAP* generateMap(int width, int height, int type, int texture, int border, int border_texture);
bobMAP* generateMap(int width, int height, MapType type, TriangleTerrainType texture, int border, int border_texture);
void loadMapPics();
void unloadMapPics();

Expand Down
Loading

0 comments on commit 54b02ed

Please sign in to comment.