summaryrefslogtreecommitdiffstats
path: root/src/Map.cpp
diff options
context:
space:
mode:
authormjagdis <mjagdis@eris-associates.co.uk>2024-11-01 23:19:34 +0100
committerGitHub <noreply@github.com>2024-11-01 23:19:34 +0100
commit4e3b272af7398df4f9313dda763930658d278aa0 (patch)
tree0612172aa6410c830fde2f52fc7121518c28eecd /src/Map.cpp
parentConvert double to ints with floor rather than truncating (#5572) (diff)
downloadcuberite-4e3b272af7398df4f9313dda763930658d278aa0.tar
cuberite-4e3b272af7398df4f9313dda763930658d278aa0.tar.gz
cuberite-4e3b272af7398df4f9313dda763930658d278aa0.tar.bz2
cuberite-4e3b272af7398df4f9313dda763930658d278aa0.tar.lz
cuberite-4e3b272af7398df4f9313dda763930658d278aa0.tar.xz
cuberite-4e3b272af7398df4f9313dda763930658d278aa0.tar.zst
cuberite-4e3b272af7398df4f9313dda763930658d278aa0.zip
Diffstat (limited to '')
-rw-r--r--src/Map.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Map.cpp b/src/Map.cpp
index 9e3c364b1..3691d0ab0 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -23,6 +23,7 @@ cMap::cMap(unsigned int a_ID, cWorld * a_World):
m_Scale(3),
m_CenterX(0),
m_CenterZ(0),
+ m_Dirty(false), // This constructor is for an empty map object which will be filled by the caller with the correct values - it does not need saving.
m_World(a_World),
m_Name(fmt::format(FMT_STRING("map_{}"), m_ID))
{
@@ -40,6 +41,7 @@ cMap::cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, un
m_Scale(a_Scale),
m_CenterX(a_CenterX),
m_CenterZ(a_CenterZ),
+ m_Dirty(true), // This constructor is for creating a brand new map in game, it will always need saving.
m_World(a_World),
m_Name(fmt::format(FMT_STRING("map_{}"), m_ID))
{
@@ -223,7 +225,13 @@ bool cMap::SetPixel(unsigned int a_X, unsigned int a_Z, cMap::ColorID a_Data)
{
if ((a_X < m_Width) && (a_Z < m_Height))
{
- m_Data[a_Z * m_Width + a_X] = a_Data;
+ auto index = a_Z * m_Width + a_X;
+
+ if (m_Data[index] != a_Data)
+ {
+ m_Data[index] = a_Data;
+ m_Dirty = true;
+ }
return true;
}