summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/colordb.cpp4
-rw-r--r--src/resources/dye.cpp2
-rw-r--r--src/resources/emotedb.cpp6
-rw-r--r--src/resources/image.cpp28
-rw-r--r--src/resources/itemdb.cpp6
-rw-r--r--src/resources/mapreader.cpp36
-rw-r--r--src/resources/monsterdb.cpp2
-rw-r--r--src/resources/resourcemanager.cpp58
-rw-r--r--src/resources/specialdb.cpp4
9 files changed, 88 insertions, 58 deletions
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index 2ddf27ac3..66c8de0a2 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -95,7 +95,7 @@ void ColorDB::loadHair()
if (colors.find(id) != colors.end())
logger->log("ColorDB: Redefinition of dye ID %d", id);
- colors[id] = ItemColor(id, XML::getProperty(node, "name", ""),
+ colors[id] = ItemColor(id, XML::langProperty(node, "name", ""),
XML::getProperty(node, hairXml ? "value" : "dye", "#FFFFFF"));
}
}
@@ -135,7 +135,7 @@ void ColorDB::loadColorLists()
if (xmlNameEqual(colorNode, "color"))
{
ItemColor c(XML::getProperty(colorNode, "id", -1),
- XML::getProperty(colorNode, "name", ""),
+ XML::langProperty(colorNode, "name", ""),
XML::getProperty(colorNode, "value", ""));
if (c.id > -1)
colors[c.id] = c;
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 6800c5170..eec5916c4 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -309,7 +309,7 @@ void Dye::instantiate(std::string &target, const std::string &palettes)
{
s << palettes.substr(pal_pos);
s << target.substr(next_pos);
- pal_pos = std::string::npos;
+ //pal_pos = std::string::npos;
break;
}
s << palettes.substr(pal_pos, pal_next_pos - pal_pos);
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index 07e192cd4..d6c01af6d 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -93,7 +93,8 @@ void EmoteDB::load()
spriteNode->xmlChildrenNode->content);
currentSprite->sprite = AnimatedSprite::load(file,
XML::getProperty(spriteNode, "variant", 0));
- currentSprite->name = XML::getProperty(spriteNode, "name", "");
+ currentSprite->name = XML::langProperty(
+ spriteNode, "name", "");
currentInfo->sprites.push_back(currentSprite);
}
else if (xmlNameEqual(spriteNode, "particlefx"))
@@ -147,7 +148,8 @@ void EmoteDB::load()
spriteNode->xmlChildrenNode->content);
currentSprite->sprite = AnimatedSprite::load(file,
XML::getProperty(spriteNode, "variant", 0));
- currentSprite->name = XML::getProperty(spriteNode, "name", "");
+ currentSprite->name = XML::langProperty(
+ spriteNode, "name", "");
currentInfo->sprites.push_back(currentSprite);
}
else if (xmlNameEqual(spriteNode, "particlefx"))
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 6f9042029..1e2bd6b51 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -250,14 +250,14 @@ Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha)
// We also delete the alpha channel since
// it's not used.
- delete[] alphaChannel;
+ delete [] alphaChannel;
alphaChannel = nullptr;
}
if (!image)
{
logger->log1("Error: Image convert failed.");
- delete[] alphaChannel;
+ delete [] alphaChannel;
return nullptr;
}
@@ -295,7 +295,7 @@ void Image::unload()
SDL_FreeSurface(mSDLSurface);
mSDLSurface = nullptr;
- delete[] mAlphaChannel;
+ delete [] mAlphaChannel;
mAlphaChannel = nullptr;
}
@@ -689,14 +689,14 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
// We also delete the alpha channel since
// it's not used.
- delete[] alphaChannel;
+ delete [] alphaChannel;
alphaChannel = nullptr;
}
if (!image)
{
logger->log1("Error: Image convert failed.");
- delete[] alphaChannel;
+ delete [] alphaChannel;
return nullptr;
}
@@ -885,10 +885,20 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
mBounds.y = static_cast<short>(y);
mBounds.w = static_cast<Uint16>(width);
mBounds.h = static_cast<Uint16>(height);
- mInternalBounds.x = mParent->mBounds.x;
- mInternalBounds.y = mParent->mBounds.y;
- mInternalBounds.w = mParent->mBounds.w;
- mInternalBounds.h = mParent->mBounds.h;
+ if (mParent)
+ {
+ mInternalBounds.x = mParent->mBounds.x;
+ mInternalBounds.y = mParent->mBounds.y;
+ mInternalBounds.w = mParent->mBounds.w;
+ mInternalBounds.h = mParent->mBounds.h;
+ }
+ else
+ {
+ mInternalBounds.x = 0;
+ mInternalBounds.y = 0;
+ mInternalBounds.w = 1;
+ mInternalBounds.h = 1;
+ }
mUseAlphaCache = false;
}
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 5fa68a88f..e81700ecc 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -202,10 +202,10 @@ void ItemDB::load()
int weight = XML::getProperty(node, "weight", 0);
int view = XML::getProperty(node, "view", 0);
- std::string name = XML::getProperty(node, "name", "");
+ std::string name = XML::langProperty(node, "name", "");
std::string image = XML::getProperty(node, "image", "");
std::string floor = XML::getProperty(node, "floor", "");
- std::string description = XML::getProperty(node, "description", "");
+ std::string description = XML::langProperty(node, "description", "");
std::string attackAction = XML::getProperty(node, "attack-action", "");
std::string drawBefore = XML::getProperty(node, "drawBefore", "");
std::string drawAfter = XML::getProperty(node, "drawAfter", "");
@@ -316,7 +316,7 @@ void ItemDB::load()
effect += " / ";
effect += strprintf(it->format.c_str(), value);
}
- std::string temp = XML::getProperty(node, "effect", "");
+ std::string temp = XML::langProperty(node, "effect", "");
if (!effect.empty() && !temp.empty())
effect += " / ";
effect += temp;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 8d71779f2..19f9ab3f2 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -22,9 +22,11 @@
#include "resources/mapreader.h"
+#include "client.h"
#include "configuration.h"
#include "logger.h"
#include "map.h"
+#include "maplayer.h"
#include "tileset.h"
#include "resources/animation.h"
@@ -459,12 +461,6 @@ void MapReader::readLayer(XmlNodePtr node, Map *map)
MapLayer *layer = nullptr;
- if (!isCollisionLayer)
- {
- layer = new MapLayer(offsetX, offsetY, w, h, isFringeLayer);
- map->addLayer(layer);
- }
-
logger->log("- Loading layer \"%s\"", name.c_str());
int x = 0;
int y = 0;
@@ -472,9 +468,33 @@ void MapReader::readLayer(XmlNodePtr node, Map *map)
// Load the tile data
for_each_xml_child_node(childNode, node)
{
+ if (serverVersion > 0 && xmlNameEqual(childNode, "properties"))
+ {
+ for_each_xml_child_node(prop, childNode)
+ {
+ if (!xmlNameEqual(prop, "property"))
+ continue;
+ const std::string pname = XML::getProperty(prop, "name", "");
+ const std::string value = XML::getProperty(prop, "value", "");
+ // ignoring any layer if property Hidden is 1
+ if (pname == "Hidden" && value == "1")
+ return;
+ if (pname == "Version" && value > CHECK_VERSION)
+ return;
+ if (pname == "NotVersion" && value <= CHECK_VERSION)
+ return;
+ }
+ }
+
if (!xmlNameEqual(childNode, "data"))
continue;
+ if (!isCollisionLayer)
+ {
+ layer = new MapLayer(offsetX, offsetY, w, h, isFringeLayer);
+ map->addLayer(layer);
+ }
+
const std::string encoding =
XML::getProperty(childNode, "encoding", "");
const std::string compression =
@@ -502,7 +522,7 @@ void MapReader::readLayer(XmlNodePtr node, Map *map)
const char *charStart = reinterpret_cast<const char*>(xmlChars);
if (!charStart)
{
- delete[] charData;
+ delete [] charData;
return;
}
@@ -525,7 +545,7 @@ void MapReader::readLayer(XmlNodePtr node, Map *map)
static_cast<int>(strlen(reinterpret_cast<char*>(
charData))), &binLen);
- delete[] charData;
+ delete [] charData;
xmlFree(xmlChars);
if (binData)
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 9d295db35..2c9448fc3 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -80,7 +80,7 @@ void MonsterDB::load()
| Map::BLOCKMASK_CHARACTER | Map::BLOCKMASK_MONSTER);
currentInfo->setBlockType(Map::BLOCKTYPE_MONSTER);
- currentInfo->setName(XML::getProperty(
+ currentInfo->setName(XML::langProperty(
monsterNode, "name", _("unnamed")));
currentInfo->setTargetCursorSize(XML::getProperty(monsterNode,
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index c26526b97..ec8764a44 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -329,12 +329,12 @@ std::string ResourceManager::getPath(const std::string &file)
// if the file is not in the search path, then its nullptr
if (tmp)
{
- path = std::string(tmp) + "/" + file;
+ path = std::string(tmp) + PHYSFS_getDirSeparator() + file;
}
else
{
// if not found in search path return the default path
- path = Client::getPackageDirectory() + "/" + file;
+ path = Client::getPackageDirectory() + PHYSFS_getDirSeparator() + file;
}
return path;
@@ -404,19 +404,19 @@ struct ResourceLoader
{
if (!v)
return nullptr;
- ResourceLoader *l = static_cast< ResourceLoader * >(v);
- SDL_RWops *rw = PHYSFSRWOPS_openRead(l->path.c_str());
+ ResourceLoader *rl = static_cast< ResourceLoader * >(v);
+ SDL_RWops *rw = PHYSFSRWOPS_openRead(rl->path.c_str());
if (!rw)
return nullptr;
- Resource *res = l->fun(rw);
+ Resource *res = rl->fun(rw);
return res;
}
};
Resource *ResourceManager::load(const std::string &path, loader fun)
{
- ResourceLoader l = { this, path, fun };
- return get(path, ResourceLoader::load, &l);
+ ResourceLoader rl = { this, path, fun };
+ return get(path, ResourceLoader::load, &rl);
}
Music *ResourceManager::getMusic(const std::string &idPath)
@@ -438,11 +438,11 @@ struct DyedImageLoader
if (!v)
return nullptr;
- DyedImageLoader *l = static_cast< DyedImageLoader * >(v);
- if (!l->manager)
+ DyedImageLoader *rl = static_cast< DyedImageLoader * >(v);
+ if (!rl->manager)
return nullptr;
- std::string path = l->path;
+ std::string path = rl->path;
std::string::size_type p = path.find('|');
Dye *d = nullptr;
if (p != std::string::npos)
@@ -465,8 +465,8 @@ struct DyedImageLoader
Image *ResourceManager::getImage(const std::string &idPath)
{
- DyedImageLoader l = { this, idPath };
- return static_cast<Image*>(get(idPath, DyedImageLoader::load, &l));
+ DyedImageLoader rl = { this, idPath };
+ return static_cast<Image*>(get(idPath, DyedImageLoader::load, &rl));
}
/*
@@ -475,8 +475,8 @@ Image *ResourceManager::getSkinImage(const std::string &idPath)
if (mSelectedSkin.empty())
return getImage(idPath);
- DyedImageLoader l = { this, mSelectedSkin + idPath };
- void *ptr = get(idPath, DyedImageLoader::load, &l);
+ DyedImageLoader rl = { this, mSelectedSkin + idPath };
+ void *ptr = get(idPath, DyedImageLoader::load, &rl);
if (ptr)
return static_cast<Image*>(ptr);
else
@@ -494,14 +494,14 @@ struct ImageSetLoader
if (!v)
return nullptr;
- ImageSetLoader *l = static_cast< ImageSetLoader * >(v);
- if (!l->manager)
+ ImageSetLoader *rl = static_cast< ImageSetLoader * >(v);
+ if (!rl->manager)
return nullptr;
- Image *img = l->manager->getImage(l->path);
+ Image *img = rl->manager->getImage(rl->path);
if (!img)
return nullptr;
- ImageSet *res = new ImageSet(img, l->w, l->h);
+ ImageSet *res = new ImageSet(img, rl->w, rl->h);
img->decRef();
return res;
}
@@ -510,10 +510,10 @@ struct ImageSetLoader
ImageSet *ResourceManager::getImageSet(const std::string &imagePath,
int w, int h)
{
- ImageSetLoader l = { this, imagePath, w, h };
+ ImageSetLoader rl = { this, imagePath, w, h };
std::stringstream ss;
ss << imagePath << "[" << w << "x" << h << "]";
- return static_cast<ImageSet*>(get(ss.str(), ImageSetLoader::load, &l));
+ return static_cast<ImageSet*>(get(ss.str(), ImageSetLoader::load, &rl));
}
struct SpriteDefLoader
@@ -525,17 +525,17 @@ struct SpriteDefLoader
if (!v)
return nullptr;
- SpriteDefLoader *l = static_cast< SpriteDefLoader * >(v);
- return SpriteDef::load(l->path, l->variant);
+ SpriteDefLoader *rl = static_cast< SpriteDefLoader * >(v);
+ return SpriteDef::load(rl->path, rl->variant);
}
};
SpriteDef *ResourceManager::getSprite(const std::string &path, int variant)
{
- SpriteDefLoader l = { path, variant };
+ SpriteDefLoader rl = { path, variant };
std::stringstream ss;
ss << path << "[" << variant << "]";
- return static_cast<SpriteDef*>(get(ss.str(), SpriteDefLoader::load, &l));
+ return static_cast<SpriteDef*>(get(ss.str(), SpriteDefLoader::load, &rl));
}
void ResourceManager::release(Resource *res)
@@ -723,10 +723,10 @@ struct RescaledLoader
{
if (!v)
return nullptr;
- RescaledLoader *l = static_cast< RescaledLoader * >(v);
- if (!l->manager)
+ RescaledLoader *rl = static_cast< RescaledLoader * >(v);
+ if (!rl->manager || !rl->image)
return nullptr;
- Image *rescaled = l->image->SDLgetScaledImage(l->width, l->height);
+ Image *rescaled = rl->image->SDLgetScaledImage(rl->width, rl->height);
if (!rescaled)
return nullptr;
return rescaled;
@@ -740,7 +740,7 @@ Image *ResourceManager::getRescaled(Image *image, int width, int height)
std::string idPath = image->getIdPath() + strprintf(
"_rescaled%dx%d", width, height);
- RescaledLoader l = { this, image, width, height };
- Image *img = static_cast<Image*>(get(idPath, RescaledLoader::load, &l));
+ RescaledLoader rl = { this, image, width, height };
+ Image *img = static_cast<Image*>(get(idPath, RescaledLoader::load, &rl));
return img;
}
diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp
index b1a3a9c4d..50ea773bc 100644
--- a/src/resources/specialdb.cpp
+++ b/src/resources/specialdb.cpp
@@ -36,7 +36,7 @@ namespace
SpecialInfo::TargetMode SpecialDB::targetModeFromString(const std::string& str)
{
- if (str == "self") return SpecialInfo::TARGET_SELF;
+ if (str == "self") return SpecialInfo::TARGET_SELF;
else if (str == "friend") return SpecialInfo::TARGET_FRIEND;
else if (str == "enemy") return SpecialInfo::TARGET_ENEMY;
else if (str == "being") return SpecialInfo::TARGET_BEING;
@@ -129,6 +129,4 @@ SpecialInfo *SpecialDB::get(int id)
return nullptr;
else
return i->second;
- return nullptr;
}
-