summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-10-10 22:14:45 +0300
committerAndrei Karas <akaras@inbox.ru>2017-10-10 22:15:57 +0300
commitaa3f63fd497558a02feb3ddbc44f31eac091f39b (patch)
tree0e28b9b1f0501dd8be9e1a38db4ec1777fa3fbfa /src/resources
parent7c10a6b61e9d06a4ae9cc9f942dfacb6fcfd9d3d (diff)
downloadplus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.gz
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.bz2
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.xz
plus-aa3f63fd497558a02feb3ddbc44f31eac091f39b.zip
Remove most unused files.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/action.cpp105
-rw-r--r--src/resources/action.h79
-rw-r--r--src/resources/ambientlayer.cpp155
-rw-r--r--src/resources/ambientlayer.h89
-rw-r--r--src/resources/animation/animation.cpp107
-rw-r--r--src/resources/animation/animation.h103
-rw-r--r--src/resources/animation/simpleanimation.cpp237
-rw-r--r--src/resources/animation/simpleanimation.h99
-rw-r--r--src/resources/atlas/atlasitem.h62
-rw-r--r--src/resources/atlas/atlasmanager.cpp555
-rw-r--r--src/resources/atlas/atlasmanager.h78
-rw-r--r--src/resources/atlas/atlasresource.cpp91
-rw-r--r--src/resources/atlas/atlasresource.h55
-rw-r--r--src/resources/atlas/textureatlas.h81
-rw-r--r--src/resources/attack.h73
-rw-r--r--src/resources/basicstat.h49
-rw-r--r--src/resources/beingcommon.cpp268
-rw-r--r--src/resources/beingcommon.h82
-rw-r--r--src/resources/beinginfo.cpp268
-rw-r--r--src/resources/beinginfo.h404
-rw-r--r--src/resources/beingmenuitem.h43
-rw-r--r--src/resources/beingslot.cpp25
-rw-r--r--src/resources/beingslot.h52
-rw-r--r--src/resources/chatobject.cpp69
-rw-r--r--src/resources/chatobject.h56
-rw-r--r--src/resources/cursors.cpp69
-rw-r--r--src/resources/cursors.h43
-rw-r--r--src/resources/db/avatardb.cpp146
-rw-r--r--src/resources/db/avatardb.h47
-rw-r--r--src/resources/db/badgesdb.cpp114
-rw-r--r--src/resources/db/badgesdb.h45
-rw-r--r--src/resources/db/chardb.cpp189
-rw-r--r--src/resources/db/chardb.h75
-rw-r--r--src/resources/db/colordb.cpp225
-rw-r--r--src/resources/db/colordb.h74
-rw-r--r--src/resources/db/commandsdb.cpp162
-rw-r--r--src/resources/db/commandsdb.h50
-rw-r--r--src/resources/db/deaddb.cpp108
-rw-r--r--src/resources/db/deaddb.h49
-rw-r--r--src/resources/db/elementaldb.cpp153
-rw-r--r--src/resources/db/elementaldb.h50
-rw-r--r--src/resources/db/emotedb.cpp317
-rw-r--r--src/resources/db/emotedb.h70
-rw-r--r--src/resources/db/groupdb.cpp394
-rw-r--r--src/resources/db/groupdb.h55
-rw-r--r--src/resources/db/homunculusdb.cpp159
-rw-r--r--src/resources/db/homunculusdb.h50
-rw-r--r--src/resources/db/horsedb.cpp302
-rw-r--r--src/resources/db/horsedb.h59
-rw-r--r--src/resources/db/itemdb.cpp1232
-rw-r--r--src/resources/db/itemdb.h78
-rw-r--r--src/resources/db/itemfielddb.cpp153
-rw-r--r--src/resources/db/itemfielddb.h49
-rw-r--r--src/resources/db/itemoptiondb.cpp151
-rw-r--r--src/resources/db/itemoptiondb.h49
-rw-r--r--src/resources/db/languagedb.cpp124
-rw-r--r--src/resources/db/languagedb.h44
-rw-r--r--src/resources/db/mapdb.cpp225
-rw-r--r--src/resources/db/mapdb.h72
-rw-r--r--src/resources/db/mercenarydb.cpp157
-rw-r--r--src/resources/db/mercenarydb.h50
-rw-r--r--src/resources/db/moddb.cpp118
-rw-r--r--src/resources/db/moddb.h46
-rw-r--r--src/resources/db/monsterdb.cpp160
-rw-r--r--src/resources/db/monsterdb.h50
-rw-r--r--src/resources/db/networkdb.cpp88
-rw-r--r--src/resources/db/networkdb.h56
-rw-r--r--src/resources/db/npcdb.cpp203
-rw-r--r--src/resources/db/npcdb.h52
-rw-r--r--src/resources/db/npcdialogdb.cpp229
-rw-r--r--src/resources/db/npcdialogdb.h60
-rw-r--r--src/resources/db/palettedb.cpp115
-rw-r--r--src/resources/db/palettedb.h39
-rw-r--r--src/resources/db/petdb.cpp167
-rw-r--r--src/resources/db/petdb.h47
-rw-r--r--src/resources/db/questdb.cpp264
-rw-r--r--src/resources/db/questdb.h55
-rw-r--r--src/resources/db/skillunitdb.cpp161
-rw-r--r--src/resources/db/skillunitdb.h47
-rw-r--r--src/resources/db/sounddb.cpp99
-rw-r--r--src/resources/db/sounddb.h42
-rw-r--r--src/resources/db/statdb.cpp235
-rw-r--r--src/resources/db/statdb.h50
-rw-r--r--src/resources/db/statuseffectdb.cpp251
-rw-r--r--src/resources/db/statuseffectdb.h76
-rw-r--r--src/resources/db/textdb.cpp104
-rw-r--r--src/resources/db/textdb.h44
-rw-r--r--src/resources/db/unitsdb.cpp400
-rw-r--r--src/resources/db/unitsdb.h68
-rw-r--r--src/resources/db/weaponsdb.cpp85
-rw-r--r--src/resources/db/weaponsdb.h44
-rw-r--r--src/resources/dbmanager.cpp139
-rw-r--r--src/resources/dbmanager.h30
-rw-r--r--src/resources/delayedmanager.cpp71
-rw-r--r--src/resources/delayedmanager.h57
-rw-r--r--src/resources/dye/dye.cpp411
-rw-r--r--src/resources/dye/dye.h95
-rw-r--r--src/resources/dye/dyecolor.h84
-rw-r--r--src/resources/dye/dyepalette.cpp311
-rw-r--r--src/resources/dye/dyepalette.h187
-rw-r--r--src/resources/dye/dyepalette_replaceacolor.cpp282
-rw-r--r--src/resources/dye/dyepalette_replaceaoglcolor.cpp398
-rw-r--r--src/resources/dye/dyepalette_replacescolor.cpp300
-rw-r--r--src/resources/dye/dyepalette_replacesoglcolor.cpp402
-rw-r--r--src/resources/dye/dyepaletteptr.h31
-rw-r--r--src/resources/effectdescription.h49
-rw-r--r--src/resources/emoteinfo.h50
-rw-r--r--src/resources/emotesprite.h46
-rw-r--r--src/resources/equipmentslots.h41
-rw-r--r--src/resources/fboinfo.h60
-rw-r--r--src/resources/frame.h50
-rw-r--r--src/resources/groupinfo.cpp37
-rw-r--r--src/resources/groupinfo.h50
-rw-r--r--src/resources/horseinfo.h56
-rw-r--r--src/resources/horseoffset.h47
-rw-r--r--src/resources/image/image.cpp527
-rw-r--r--src/resources/image/image.h258
-rw-r--r--src/resources/image/subimage.cpp233
-rw-r--r--src/resources/image/subimage.h84
-rw-r--r--src/resources/imagehelper.cpp256
-rw-r--r--src/resources/imagehelper.h122
-rw-r--r--src/resources/imagerect.h44
-rw-r--r--src/resources/imageset.cpp82
-rw-r--r--src/resources/imageset.h98
-rw-r--r--src/resources/inventory/complexinventory.cpp170
-rw-r--r--src/resources/inventory/complexinventory.h65
-rw-r--r--src/resources/inventory/inventory.cpp556
-rw-r--r--src/resources/inventory/inventory.h219
-rw-r--r--src/resources/item/cardslist.cpp25
-rw-r--r--src/resources/item/cardslist.h72
-rw-r--r--src/resources/item/complexitem.cpp96
-rw-r--r--src/resources/item/complexitem.h65
-rw-r--r--src/resources/item/item.cpp198
-rw-r--r--src/resources/item/item.h267
-rw-r--r--src/resources/item/itemfieldtype.h45
-rw-r--r--src/resources/item/itemoption.h39
-rw-r--r--src/resources/item/itemoptionslist.h102
-rw-r--r--src/resources/item/shopitem.cpp174
-rw-r--r--src/resources/item/shopitem.h181
-rw-r--r--src/resources/itemcolordata.h56
-rw-r--r--src/resources/iteminfo.cpp483
-rw-r--r--src/resources/iteminfo.h397
-rw-r--r--src/resources/itemmenuitem.h49
-rw-r--r--src/resources/itemtypemap.h40
-rw-r--r--src/resources/itemtypemapdata.h107
-rw-r--r--src/resources/loaders/atlasloader.cpp62
-rw-r--r--src/resources/loaders/atlasloader.h38
-rw-r--r--src/resources/loaders/emptyatlasloader.cpp63
-rw-r--r--src/resources/loaders/emptyatlasloader.h38
-rw-r--r--src/resources/loaders/imageloader.cpp90
-rw-r--r--src/resources/loaders/imageloader.h41
-rw-r--r--src/resources/loaders/imagesetloader.cpp79
-rw-r--r--src/resources/loaders/imagesetloader.h43
-rw-r--r--src/resources/loaders/musicloader.cpp81
-rw-r--r--src/resources/loaders/musicloader.h41
-rw-r--r--src/resources/loaders/rescaledloader.cpp76
-rw-r--r--src/resources/loaders/rescaledloader.h37
-rw-r--r--src/resources/loaders/shaderloader.cpp67
-rw-r--r--src/resources/loaders/shaderloader.h41
-rw-r--r--src/resources/loaders/shaderprogramloader.cpp73
-rw-r--r--src/resources/loaders/shaderprogramloader.h42
-rw-r--r--src/resources/loaders/soundloader.cpp75
-rw-r--r--src/resources/loaders/soundloader.h41
-rw-r--r--src/resources/loaders/spritedefloader.cpp69
-rw-r--r--src/resources/loaders/spritedefloader.h43
-rw-r--r--src/resources/loaders/subimageloader.cpp90
-rw-r--r--src/resources/loaders/subimageloader.h39
-rw-r--r--src/resources/loaders/subimagesetloader.cpp78
-rw-r--r--src/resources/loaders/subimagesetloader.h38
-rw-r--r--src/resources/loaders/walklayerloader.cpp71
-rw-r--r--src/resources/loaders/walklayerloader.h39
-rw-r--r--src/resources/loaders/xmlloader.cpp62
-rw-r--r--src/resources/loaders/xmlloader.h38
-rw-r--r--src/resources/mailqueue.h49
-rw-r--r--src/resources/map/location.h60
-rw-r--r--src/resources/map/map.cpp1786
-rw-r--r--src/resources/map/map.h495
-rw-r--r--src/resources/map/mapheights.cpp49
-rw-r--r--src/resources/map/mapheights.h60
-rw-r--r--src/resources/map/mapitem.cpp174
-rw-r--r--src/resources/map/mapitem.h92
-rw-r--r--src/resources/map/maplayer.cpp853
-rw-r--r--src/resources/map/maplayer.h229
-rw-r--r--src/resources/map/mapobject.h46
-rw-r--r--src/resources/map/mapobjectlist.h45
-rw-r--r--src/resources/map/maprowvertexes.h52
-rw-r--r--src/resources/map/metatile.h53
-rw-r--r--src/resources/map/objectslayer.cpp86
-rw-r--r--src/resources/map/objectslayer.h57
-rw-r--r--src/resources/map/properties.h136
-rw-r--r--src/resources/map/speciallayer.cpp189
-rw-r--r--src/resources/map/speciallayer.h85
-rw-r--r--src/resources/map/tileanimation.cpp67
-rw-r--r--src/resources/map/tileanimation.h66
-rw-r--r--src/resources/map/tileinfo.h53
-rw-r--r--src/resources/map/tileset.h101
-rw-r--r--src/resources/map/walklayer.cpp51
-rw-r--r--src/resources/map/walklayer.h53
-rw-r--r--src/resources/mapinfo.h43
-rw-r--r--src/resources/mapreader.cpp1324
-rw-r--r--src/resources/mapreader.h123
-rw-r--r--src/resources/memorycounter.cpp50
-rw-r--r--src/resources/memorycounter.h51
-rw-r--r--src/resources/memorymanager.cpp99
-rw-r--r--src/resources/memorymanager.h54
-rw-r--r--src/resources/missileinfo.h47
-rw-r--r--src/resources/mobileopenglscreenshothelper.cpp131
-rw-r--r--src/resources/mobileopenglscreenshothelper.h52
-rw-r--r--src/resources/modinfo.cpp34
-rw-r--r--src/resources/modinfo.h71
-rw-r--r--src/resources/mstack.h100
-rw-r--r--src/resources/notificationinfo.h47
-rw-r--r--src/resources/notifications.h914
-rw-r--r--src/resources/npcbuttoninfo.h52
-rw-r--r--src/resources/npcdialoginfo.h47
-rw-r--r--src/resources/npcdialogmenuinfo.h48
-rw-r--r--src/resources/npcimageinfo.h44
-rw-r--r--src/resources/npcinventoryinfo.h42
-rw-r--r--src/resources/npctextinfo.h48
-rw-r--r--src/resources/openglimagehelper.cpp528
-rw-r--r--src/resources/openglimagehelper.h162
-rw-r--r--src/resources/openglscreenshothelper.cpp107
-rw-r--r--src/resources/openglscreenshothelper.h52
-rw-r--r--src/resources/questeffect.h51
-rw-r--r--src/resources/questitem.h58
-rw-r--r--src/resources/questitemtext.h51
-rw-r--r--src/resources/questvar.h60
-rw-r--r--src/resources/rect/doublerect.h39
-rw-r--r--src/resources/resource.cpp80
-rw-r--r--src/resources/resource.h95
-rw-r--r--src/resources/resourcefunctiontypes.h41
-rw-r--r--src/resources/resourcemanager/resourcemanager.cpp711
-rw-r--r--src/resources/resourcemanager/resourcemanager.h125
-rw-r--r--src/resources/resourcetypes.h41
-rw-r--r--src/resources/safeopenglimagehelper.cpp501
-rw-r--r--src/resources/safeopenglimagehelper.h162
-rw-r--r--src/resources/screenshothelper.h51
-rw-r--r--src/resources/sdl2imagehelper.cpp109
-rw-r--r--src/resources/sdl2imagehelper.h100
-rw-r--r--src/resources/sdl2softwareimagehelper.cpp83
-rw-r--r--src/resources/sdl2softwareimagehelper.h96
-rw-r--r--src/resources/sdl2softwarescreenshothelper.cpp85
-rw-r--r--src/resources/sdl2softwarescreenshothelper.h47
-rw-r--r--src/resources/sdlgfxblitfunc.cpp542
-rw-r--r--src/resources/sdlgfxblitfunc.h42
-rw-r--r--src/resources/sdlimagehelper.cpp339
-rw-r--r--src/resources/sdlimagehelper.h106
-rw-r--r--src/resources/sdlmusic.cpp73
-rw-r--r--src/resources/sdlmusic.h83
-rw-r--r--src/resources/sdlscreenshothelper.cpp80
-rw-r--r--src/resources/sdlscreenshothelper.h44
-rw-r--r--src/resources/servercommands.inc290
-rw-r--r--src/resources/serverpermissions.inc54
-rw-r--r--src/resources/skill/skilldata.cpp80
-rw-r--r--src/resources/skill/skilldata.h67
-rw-r--r--src/resources/skill/skillinfo.cpp204
-rw-r--r--src/resources/skill/skillinfo.h108
-rw-r--r--src/resources/skill/skilltypeentry.h36
-rw-r--r--src/resources/skill/skilltypelist.h48
-rw-r--r--src/resources/soundeffect.cpp45
-rw-r--r--src/resources/soundeffect.h81
-rw-r--r--src/resources/soundinfo.h51
-rw-r--r--src/resources/sprite/animatedsprite.cpp485
-rw-r--r--src/resources/sprite/animatedsprite.h186
-rw-r--r--src/resources/sprite/animationdelayload.cpp65
-rw-r--r--src/resources/sprite/animationdelayload.h55
-rw-r--r--src/resources/sprite/imagesprite.cpp60
-rw-r--r--src/resources/sprite/imagesprite.h82
-rw-r--r--src/resources/sprite/sprite.h132
-rw-r--r--src/resources/sprite/spritedef.cpp694
-rw-r--r--src/resources/sprite/spritedef.h166
-rw-r--r--src/resources/sprite/spritedisplay.h50
-rw-r--r--src/resources/sprite/spritereference.h53
-rw-r--r--src/resources/surfaceimagehelper.cpp86
-rw-r--r--src/resources/surfaceimagehelper.h95
-rw-r--r--src/resources/updatefile.h53
-rw-r--r--src/resources/wallpaper.cpp166
-rw-r--r--src/resources/wallpaper.h56
-rw-r--r--src/resources/wallpaperdata.h46
279 files changed, 0 insertions, 38864 deletions
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
deleted file mode 100644
index 9b3dab3f4..000000000
--- a/src/resources/action.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/action.h"
-
-#include "resources/animation/animation.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-Action::Action(const std::string &name) noexcept2 :
- MemoryCounter(),
- mAnimations(),
- mCounterName(name),
- mNumber(100)
-{
-}
-
-Action::~Action()
-{
- delete_all(mAnimations);
-}
-
-const Animation *Action::getAnimation(SpriteDirection::Type direction)
- const noexcept2
-{
- Animations::const_iterator i = mAnimations.find(direction);
-
- if (i == mAnimations.end())
- {
- if (direction == SpriteDirection::UPLEFT
- || direction == SpriteDirection::UPRIGHT)
- {
- direction = SpriteDirection::UP;
- }
- else if (direction == SpriteDirection::DOWNLEFT
- || direction == SpriteDirection::DOWNRIGHT)
- {
- direction = SpriteDirection::DOWN;
- }
- i = mAnimations.find(direction);
-
- // When the given direction is not available, return the first one.
- // (either DEFAULT, or more usually DOWN).
- if (i == mAnimations.end())
- i = mAnimations.begin();
- }
-
- return (i == mAnimations.end()) ? nullptr : i->second;
-}
-
-void Action::setAnimation(const SpriteDirection::Type direction,
- Animation *const animation) noexcept2
-{
- mAnimations[direction] = animation;
-}
-
-void Action::setLastFrameDelay(const int delay) noexcept2
-{
- FOR_EACH (AnimationIter, it, mAnimations)
- {
- Animation *const animation = (*it).second;
- if (animation == nullptr)
- continue;
- animation->setLastFrameDelay(delay);
- }
-}
-
-int Action::calcMemoryLocal() const
-{
- return sizeof(Action);
-}
-
-int Action::calcMemoryChilds(const int level) const
-{
- int sz = 0;
- FOR_EACH (AnimationCIter, it, mAnimations)
- {
- sz += sizeof(SpriteDirection::Type);
- const Animation *const animation = (*it).second;
- sz += animation->calcMemory(level + 1);
- }
- return sz;
-}
diff --git a/src/resources/action.h b/src/resources/action.h
deleted file mode 100644
index 4a8527603..000000000
--- a/src/resources/action.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ACTION_H
-#define RESOURCES_ACTION_H
-
-#include "enums/resources/spritedirection.h"
-
-#include "resources/memorycounter.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-class Animation;
-
-/**
- * An action consists of several animations, one for each direction.
- */
-class Action final : public MemoryCounter
-{
- public:
- explicit Action(const std::string &name) noexcept2;
-
- A_DELETE_COPY(Action)
-
- ~Action();
-
- void setAnimation(const SpriteDirection::Type direction,
- Animation *const animation) noexcept2;
-
- const Animation *getAnimation(SpriteDirection::Type direction) const
- noexcept2 A_WARN_UNUSED;
-
- unsigned getNumber() const noexcept2 A_WARN_UNUSED
- { return mNumber; }
-
- void setNumber(const unsigned n) noexcept2
- { mNumber = n; }
-
- void setLastFrameDelay(const int delay) noexcept2;
-
- int calcMemoryLocal() const override final;
-
- int calcMemoryChilds(const int level) const override final;
-
- std::string getCounterName() const override
- { return mCounterName; }
-
- protected:
- typedef std::map<SpriteDirection::Type, Animation*> Animations;
- typedef Animations::iterator AnimationIter;
- typedef Animations::const_iterator AnimationCIter;
-
- Animations mAnimations;
- std::string mCounterName;
- unsigned mNumber;
-};
-
-#endif // RESOURCES_ACTION_H
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
deleted file mode 100644
index fe702ccde..000000000
--- a/src/resources/ambientlayer.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/ambientlayer.h"
-
-#include "const/render/graphics.h"
-
-#include "render/graphics.h"
-
-#include "resources/imagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/rescaledloader.h"
-
-#include "debug.h"
-
-AmbientLayer::AmbientLayer(const std::string &name,
- Image *const img,
- const float parallaxX,
- const float parallaxY,
- const float posX,
- const float posY,
- const float speedX,
- const float speedY,
- const bool keepRatio,
- const int mask) :
- MemoryCounter(),
- mName(name),
- mImage(img),
- mParallaxX(parallaxX),
- mParallaxY(parallaxY),
- mPosX(posX),
- mPosY(posY),
- mSpeedX(speedX),
- mSpeedY(speedY),
- mMask(mask),
- mKeepRatio(keepRatio)
-{
- if (mImage == nullptr)
- return;
-
- if (keepRatio &&
- imageHelper->useOpenGL() == RENDER_SOFTWARE)
- {
- const int width = mainGraphics->mWidth;
- const int height = mainGraphics->mHeight;
- if (width != defaultScreenWidth && height != defaultScreenHeight)
- {
- // Rescale the overlay to keep the ratio as if we were on
- // the default resolution...
- Image *const rescaledOverlay = Loader::getRescaled(
- mImage,
- CAST_S32(mImage->mBounds.w) /
- defaultScreenWidth * width,
- CAST_S32(mImage->mBounds.h) /
- defaultScreenHeight * height);
-
- if (rescaledOverlay != nullptr)
- mImage = rescaledOverlay;
- else
- mImage->incRef();
- return;
- }
- }
- mImage->incRef();
-}
-
-AmbientLayer::~AmbientLayer()
-{
- if (mImage != nullptr)
- {
- mImage->decRef();
- mImage = nullptr;
- }
-}
-
-void AmbientLayer::update(const int timePassed, const float dx, const float dy)
-{
- if (mImage == nullptr)
- return;
-
- const float time = static_cast<float>(timePassed) / 10;
- // Self scrolling of the overlay
- mPosX -= mSpeedX * time;
- mPosY -= mSpeedY * time;
-
- // Parallax scrolling
- mPosX += dx * mParallaxX;
- mPosY += dy * mParallaxY;
-
- const SDL_Rect &rect = mImage->mBounds;
- const float imgW = static_cast<float>(rect.w);
- const float imgH = static_cast<float>(rect.h);
-
- // Wrap values
- while (mPosX > imgW)
- mPosX -= imgW;
- while (mPosX < 0)
- mPosX += imgW;
-
- while (mPosY > imgH)
- mPosY -= imgH;
- while (mPosY < 0)
- mPosY += imgH;
-}
-
-void AmbientLayer::draw(Graphics *const graphics, const int x,
- const int y) const
-{
- if (mImage == nullptr)
- return;
-
- if (imageHelper->useOpenGL() == RENDER_SOFTWARE ||
- !mKeepRatio)
- {
- graphics->drawPattern(mImage, CAST_S32(-mPosX),
- CAST_S32(-mPosY), x + CAST_S32(mPosX),
- y + CAST_S32(mPosY));
- }
- else
- {
- graphics->drawRescaledPattern(mImage, CAST_S32(-mPosX),
- CAST_S32(-mPosY), x + CAST_S32(mPosX),
- y + CAST_S32(mPosY),
- CAST_S32(mImage->mBounds.w)
- / defaultScreenWidth * graphics->mWidth,
- CAST_S32(mImage->mBounds.h) / defaultScreenHeight
- * graphics->mHeight);
- }
-}
-
-int AmbientLayer::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(AmbientLayer) +
- mName.capacity());
-}
diff --git a/src/resources/ambientlayer.h b/src/resources/ambientlayer.h
deleted file mode 100644
index 255d62731..000000000
--- a/src/resources/ambientlayer.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_AMBIENTLAYER_H
-#define RESOURCES_AMBIENTLAYER_H
-
-#include "resources/memorycounter.h"
-
-#include "localconsts.h"
-
-class Graphics;
-class Image;
-class Map;
-
-class AmbientLayer final : public MemoryCounter
-{
- public:
- friend class Map;
-
- /**
- * Constructor.
- *
- * @param img the image this overlay displays
- * @param parallax scroll factor based on camera position
- * @param speedX scrolling speed in x-direction
- * @param speedY scrolling speed in y-direction
- * @param keepRatio rescale the image to keep
- * the same ratio than in 800x600 resolution mode.
- */
- AmbientLayer(const std::string &name,
- Image *const img,
- const float parallax,
- const float parallaxY,
- const float posX,
- const float posY,
- const float speedX,
- const float speedY,
- const bool keepRatio,
- const int mask);
-
- A_DELETE_COPY(AmbientLayer)
-
- ~AmbientLayer();
-
- void update(const int timePassed,
- const float dx,
- const float dy);
-
- void draw(Graphics *const graphics,
- const int x,
- const int y) const A_NONNULL(2);
-
- int calcMemoryLocal() const override;
-
- std::string getCounterName() const override final
- { return mName; }
-
- private:
- const std::string mName;
- Image *mImage;
- float mParallaxX;
- float mParallaxY;
- float mPosX; /**< Current layer X position. */
- float mPosY; /**< Current layer Y position. */
- float mSpeedX; /**< Scrolling speed in X direction. */
- float mSpeedY; /**< Scrolling speed in Y direction. */
- int mMask;
- bool mKeepRatio; /**< Keep overlay ratio on every resolution */
-};
-
-#endif // RESOURCES_AMBIENTLAYER_H
diff --git a/src/resources/animation/animation.cpp b/src/resources/animation/animation.cpp
deleted file mode 100644
index 3b9619009..000000000
--- a/src/resources/animation/animation.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/animation/animation.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-Animation::Animation() noexcept2 :
- MemoryCounter(),
- mFrames(),
- mName("animation"),
- mDuration(0)
-{
-}
-
-Animation::Animation(const std::string &name) noexcept2 :
- MemoryCounter(),
- mFrames(),
- mName(name),
- mDuration(0)
-{
-}
-
-void Animation::addFrame(Image *const image, const int delay,
- const int offsetX, const int offsetY,
- const int rand) noexcept2
-{
- Frame frame
- = { image, delay, offsetX, offsetY, rand, FrameType::ANIMATION, "" };
- mFrames.push_back(frame);
- mDuration += delay;
-}
-
-void Animation::addTerminator(const int rand) noexcept2
-{
- addFrame(nullptr, 0, 0, 0, rand);
-}
-
-void Animation::addJump(const std::string &name, const int rand) noexcept2
-{
- const Frame frame = { nullptr, 0, 0, 0, rand, FrameType::JUMP, name };
- mFrames.push_back(frame);
-}
-
-void Animation::addLabel(const std::string &name) noexcept2
-{
- const Frame frame = { nullptr, 0, 0, 0, 100, FrameType::LABEL, name };
- mFrames.push_back(frame);
-}
-
-void Animation::addGoto(const std::string &name, const int rand) noexcept2
-{
- const Frame frame = { nullptr, 0, 0, 0, rand, FrameType::GOTO, name };
- mFrames.push_back(frame);
-}
-
-void Animation::addPause(const int delay, const int rand) noexcept2
-{
- const Frame frame = { nullptr, delay, 0, 0, rand, FrameType::PAUSE, "" };
- mFrames.push_back(frame);
-}
-
-void Animation::setLastFrameDelay(const int delay) noexcept2
-{
- for (FramesRevIter it = mFrames.rbegin(), it_end = mFrames.rend();
- it != it_end; ++ it)
- {
- if ((*it).type == FrameType::ANIMATION && ((*it).image != nullptr))
- {
- (*it).delay = delay;
- break;
- }
- }
-}
-
-int Animation::calcMemoryLocal() const
-{
- int sz = sizeof(Animation);
- FOR_EACH (FramesCIter, it, mFrames)
- {
- const Frame &frame = *it;
- sz += static_cast<int>(sizeof(Frame) +
- frame.nextAction.capacity());
- }
- return sz;
-}
diff --git a/src/resources/animation/animation.h b/src/resources/animation/animation.h
deleted file mode 100644
index a922f989b..000000000
--- a/src/resources/animation/animation.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ANIMATION_ANIMATION_H
-#define RESOURCES_ANIMATION_ANIMATION_H
-
-#include "resources/memorycounter.h"
-
-#include "utils/vector.h"
-
-#include "resources/frame.h"
-
-#include "localconsts.h"
-
-class Image;
-
-/**
- * An animation consists of several frames, each with their own delay and
- * offset.
- */
-class Animation final : public MemoryCounter
-{
- friend class AnimatedSprite;
- friend class ParticleEmitter;
- friend class SimpleAnimation;
-
- public:
- Animation() noexcept2;
-
- explicit Animation(const std::string &name) noexcept2;
-
- A_DEFAULT_COPY(Animation)
-
- /**
- * Appends a new animation at the end of the sequence.
- */
- void addFrame(Image *const image, const int delay,
- const int offsetX, const int offsetY,
- const int rand) noexcept2;
-
- /**
- * Appends an animation terminator that states that the animation
- * should not loop.
- */
- void addTerminator(const int rand) noexcept2;
-
- /**
- * Returns the length of this animation in frames.
- */
- size_t getLength() const noexcept2 A_WARN_UNUSED
- { return mFrames.size(); }
-
- void addJump(const std::string &name, const int rand) noexcept2;
-
- void addLabel(const std::string &name) noexcept2;
-
- void addGoto(const std::string &name, const int rand) noexcept2;
-
- void addPause(const int delay, const int rand) noexcept2;
-
- void setLastFrameDelay(const int delay) noexcept2;
-
- typedef STD_VECTOR<Frame> Frames;
- typedef Frames::iterator FramesIter;
- typedef Frames::const_iterator FramesCIter;
- typedef Frames::reverse_iterator FramesRevIter;
-
-#ifdef UNITTESTS
- Frames &getFrames() noexcept2
- { return mFrames; }
-#endif // UNITTESTS
-
- int calcMemoryLocal() const override final;
-
- std::string getCounterName() const override
- { return mName; }
-
- protected:
- Frames mFrames;
- std::string mName;
- int mDuration;
-};
-
-#endif // RESOURCES_ANIMATION_ANIMATION_H
diff --git a/src/resources/animation/simpleanimation.cpp b/src/resources/animation/simpleanimation.cpp
deleted file mode 100644
index 3ee18830d..000000000
--- a/src/resources/animation/simpleanimation.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/animation/simpleanimation.h"
-
-#include "const/resources/map/map.h"
-
-#include "render/graphics.h"
-
-#include "resources/imageset.h"
-
-#include "resources/animation/animation.h"
-
-#include "resources/dye/dye.h"
-
-#include "resources/loaders/imagesetloader.h"
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-SimpleAnimation::SimpleAnimation(Animation *const animation) :
- mAnimation(animation),
- mAnimationTime(0),
- mAnimationPhase(0),
- mCurrentFrame(mAnimation != nullptr ? &mAnimation->mFrames[0] : nullptr),
- mInitialized(true),
- mImageSet(nullptr)
-{
-}
-
-SimpleAnimation::SimpleAnimation(XmlNodeConstPtr animationNode,
- const std::string& dyePalettes) :
- mAnimation(new Animation("simple animation")),
- mAnimationTime(0),
- mAnimationPhase(0),
- mCurrentFrame(nullptr),
- mInitialized(false),
- mImageSet(nullptr)
-{
- initializeAnimation(animationNode, dyePalettes);
- if (mAnimation != nullptr)
- mCurrentFrame = &mAnimation->mFrames[0];
- else
- mCurrentFrame = nullptr;
-}
-
-SimpleAnimation::~SimpleAnimation()
-{
- delete2(mAnimation);
- if (mImageSet != nullptr)
- {
- mImageSet->decRef();
- mImageSet = nullptr;
- }
-}
-
-void SimpleAnimation::draw(Graphics *const graphics,
- const int posX, const int posY) const
-{
- FUNC_BLOCK("SimpleAnimation::draw", 1)
- if ((mCurrentFrame == nullptr) || (mCurrentFrame->image == nullptr))
- return;
-
- graphics->drawImage(mCurrentFrame->image,
- posX + mCurrentFrame->offsetX,
- posY + mCurrentFrame->offsetY);
-}
-
-void SimpleAnimation::reset()
-{
- mAnimationTime = 0;
- mAnimationPhase = 0;
-}
-
-void SimpleAnimation::setFrame(int frame)
-{
- if (mAnimation == nullptr)
- return;
-
- if (frame < 0)
- frame = 0;
- const unsigned int len = CAST_U32(mAnimation->getLength());
- if (CAST_U32(frame) >= len)
- frame = len - 1;
- mAnimationPhase = frame;
- mCurrentFrame = &mAnimation->mFrames[frame];
-}
-
-bool SimpleAnimation::update(const int timePassed)
-{
- if ((mCurrentFrame == nullptr) || (mAnimation == nullptr) || !mInitialized)
- return false;
-
- bool updated(false);
- mAnimationTime += timePassed;
-
- while (mAnimationTime > mCurrentFrame->delay && mCurrentFrame->delay > 0)
- {
- updated = true;
- mAnimationTime -= mCurrentFrame->delay;
- mAnimationPhase++;
-
- if (CAST_SIZE(mAnimationPhase) >= mAnimation->getLength())
- mAnimationPhase = 0;
-
- mCurrentFrame = &mAnimation->mFrames[mAnimationPhase];
- }
- return updated;
-}
-
-int SimpleAnimation::getLength() const
-{
- if (mAnimation == nullptr)
- return 0;
-
- return CAST_S32(mAnimation->getLength());
-}
-
-Image *SimpleAnimation::getCurrentImage() const
-{
- if (mCurrentFrame != nullptr)
- return mCurrentFrame->image;
- return nullptr;
-}
-
-void SimpleAnimation::initializeAnimation(XmlNodeConstPtr animationNode,
- const std::string &dyePalettes)
-{
- mInitialized = false;
-
- if (animationNode == nullptr)
- return;
-
- std::string imagePath = XML::getProperty(
- animationNode, "imageset", "");
-
- // Instanciate the dye coloration.
- if (!imagePath.empty() && !dyePalettes.empty())
- Dye::instantiate(imagePath, dyePalettes);
-
- const ImageSet *const imageset = Loader::getImageSet(
- XML::getProperty(animationNode, "imageset", ""),
- XML::getProperty(animationNode, "width", 0),
- XML::getProperty(animationNode, "height", 0));
-
- if (imageset == nullptr)
- return;
-
- const int x1 = imageset->getWidth() / 2 - mapTileSize / 2;
- const int y1 = imageset->getHeight() - mapTileSize;
-
- // Get animation frames
- for_each_xml_child_node (frameNode, animationNode)
- {
- const int delay = XML::getIntProperty(
- frameNode, "delay", 0, 0, 100000);
- const int offsetX = XML::getProperty(frameNode, "offsetX", 0) - x1;
- const int offsetY = XML::getProperty(frameNode, "offsetY", 0) - y1;
- const int rand = XML::getIntProperty(frameNode, "rand", 100, 0, 100);
-
- if (xmlNameEqual(frameNode, "frame"))
- {
- const int index = XML::getProperty(frameNode, "index", -1);
-
- if (index < 0)
- {
- reportAlways("No valid value for 'index'");
- continue;
- }
-
- Image *const img = imageset->get(index);
-
- if (img == nullptr)
- {
- reportAlways("No image at index %d", index);
- continue;
- }
-
- if (mAnimation != nullptr)
- mAnimation->addFrame(img, delay, offsetX, offsetY, rand);
- }
- else if (xmlNameEqual(frameNode, "sequence"))
- {
- int start = XML::getProperty(frameNode, "start", -1);
- const int end = XML::getProperty(frameNode, "end", -1);
-
- if (start < 0 || end < 0)
- {
- reportAlways("No valid value for 'start' or 'end'");
- continue;
- }
-
- while (end >= start)
- {
- Image *const img = imageset->get(start);
-
- if (img == nullptr)
- {
- reportAlways("No image at index %d", start);
- continue;
- }
-
- if (mAnimation != nullptr)
- mAnimation->addFrame(img, delay, offsetX, offsetY, rand);
- start++;
- }
- }
- else if (xmlNameEqual(frameNode, "end"))
- {
- if (mAnimation != nullptr)
- mAnimation->addTerminator(rand);
- }
- }
-
- mInitialized = true;
-}
diff --git a/src/resources/animation/simpleanimation.h b/src/resources/animation/simpleanimation.h
deleted file mode 100644
index 2c068acff..000000000
--- a/src/resources/animation/simpleanimation.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ANIMATION_SIMPLEANIMATION_H
-#define RESOURCES_ANIMATION_SIMPLEANIMATION_H
-
-#include "utils/xml.h"
-
-#include "localconsts.h"
-
-class Animation;
-class Graphics;
-class Image;
-class ImageSet;
-
-struct Frame;
-
-/**
- * This class is a leightweight alternative to the AnimatedSprite class.
- * It hosts a looping animation without actions and directions.
- */
-class SimpleAnimation final
-{
- public:
- /**
- * Creates a simple animation with an already created \a animation.
- * Takes ownership over the given animation.
- */
- explicit SimpleAnimation(Animation *const animation);
-
- /**
- * Creates a simple animation that creates its animation from XML Data.
- */
- SimpleAnimation(XmlNodeConstPtr animationNode,
- const std::string& dyePalettes);
-
- A_DELETE_COPY(SimpleAnimation)
-
- ~SimpleAnimation();
-
- void setFrame(int frame);
-
- int getLength() const A_WARN_UNUSED;
-
- bool update(const int timePassed);
-
- void draw(Graphics *const graphics,
- const int posX, const int posY) const A_NONNULL(2);
-
- /**
- * Resets the animation.
- */
- void reset();
-
- Image *getCurrentImage() const A_WARN_UNUSED;
-
- private:
- void initializeAnimation(XmlNodeConstPtr animationNode,
- const std::string&
- dyePalettes = std::string());
-
- /** The hosted animation. */
- Animation *mAnimation;
-
- /** Time in game ticks the current frame is shown. */
- int mAnimationTime;
-
- /** Index of current animation phase. */
- int mAnimationPhase;
-
- /** Current animation phase. */
- const Frame *mCurrentFrame;
-
- /** Tell whether the animation is ready */
- bool mInitialized;
-
- ImageSet *mImageSet;
-};
-
-#endif // RESOURCES_ANIMATION_SIMPLEANIMATION_H
diff --git a/src/resources/atlas/atlasitem.h b/src/resources/atlas/atlasitem.h
deleted file mode 100644
index 4da78af6e..000000000
--- a/src/resources/atlas/atlasitem.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ATLAS_ATLASITEM_H
-#define RESOURCES_ATLAS_ATLASITEM_H
-
-#ifdef USE_OPENGL
-
-#include "resources/image/image.h"
-
-struct AtlasItem final : public MemoryCounter
-{
- explicit AtlasItem(Image *const image0) :
- MemoryCounter(),
- image(image0),
- name(),
- x(0),
- y(0),
- width(image0 != nullptr ? image0->mBounds.w : 0),
- height(image0 != nullptr ? image0->mBounds.h : 0)
- {
- }
-
- A_DELETE_COPY(AtlasItem)
-
- int calcMemoryLocal() const override final
- {
- return static_cast<int>(sizeof(AtlasItem) +
- name.capacity());
- // +++ here need print, but not add to sum size of image
- }
-
- std::string getCounterName() const override
- { return name; }
-
- Image *image;
- std::string name;
- int x;
- int y;
- int width;
- int height;
-};
-
-#endif // USE_OPENGL
-#endif // RESOURCES_ATLAS_ATLASITEM_H
diff --git a/src/resources/atlas/atlasmanager.cpp b/src/resources/atlas/atlasmanager.cpp
deleted file mode 100644
index 888af7fe7..000000000
--- a/src/resources/atlas/atlasmanager.cpp
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "resources/atlas/atlasmanager.h"
-
-#include "settings.h"
-
-#ifdef DEBUG_IMAGES
-#include "logger.h"
-#endif // DEBUG_IMAGES
-
-#include "fs/virtfs/rwops.h"
-
-#include "utils/mathutils.h"
-#include "utils/sdlcheckutils.h"
-
-#include "resources/openglimagehelper.h"
-
-#include "resources/atlas/atlasresource.h"
-#include "resources/atlas/textureatlas.h"
-
-#include "resources/dye/dye.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-AtlasManager::AtlasManager()
-{
-}
-
-AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name,
- const StringVect &files)
-{
- BLOCK_START("AtlasManager::loadTextureAtlas")
- STD_VECTOR<TextureAtlas*> atlases;
- STD_VECTOR<Image*> images;
- AtlasResource *resource = new AtlasResource;
-
- loadImages(files, images);
- int maxSize = OpenGLImageHelper::getTextureSize();
-#if !defined(ANDROID) && !defined(__APPLE__)
- int sz = settings.textureSize;
- if (maxSize > sz)
- maxSize = sz;
-#endif // !defined(ANDROID) && !defined(__APPLE__)
-
- // sorting images on atlases.
- simpleSort(name, atlases, images, maxSize);
-
- FOR_EACH (STD_VECTOR<TextureAtlas*>::iterator, it, atlases)
- {
- TextureAtlas *const atlas = *it;
- if (atlas == nullptr)
- continue;
-
- createSDLAtlas(atlas);
- if (atlas->atlasImage == nullptr)
- continue;
- convertAtlas(atlas);
- resource->atlases.push_back(atlas);
- }
-
- BLOCK_END("AtlasManager::loadTextureAtlas")
- return resource;
-}
-
-AtlasResource *AtlasManager::loadEmptyAtlas(const std::string &name,
- const StringVect &files)
-{
- STD_VECTOR<TextureAtlas*> atlases;
- STD_VECTOR<Image*> images;
- AtlasResource *resource = new AtlasResource;
-
- loadEmptyImages(files, images);
-
- // sorting images on atlases.
- emptySort(name, atlases, images);
-
- FOR_EACH (STD_VECTOR<TextureAtlas*>::iterator, it, atlases)
- {
- TextureAtlas *const atlas = *it;
- if (atlas == nullptr)
- continue;
-
- atlas->atlasImage = new Image(0,
- 1024, 1024,
- 1024, 1024);
- // convert SDL images to OpenGL
- convertEmptyAtlas(atlas);
-
- resource->atlases.push_back(atlas);
- }
-
- BLOCK_END("AtlasManager::loadTextureAtlas")
- return resource;
-}
-
-void AtlasManager::loadImages(const StringVect &files,
- STD_VECTOR<Image*> &images)
-{
- BLOCK_START("AtlasManager::loadImages")
-
- FOR_EACH (StringVectCIter, it, files)
- {
- const std::string str = *it;
- // check is image with same name already in cache
- // and if yes, move it to deleted set
- Resource *const res = ResourceManager::getTempResource(str);
- if (res != nullptr)
- {
- // increase counter because in moveToDeleted it will be decreased.
- res->incRef();
- ResourceManager::moveToDeleted(res);
- }
-
- std::string path = str;
- const size_t p = path.find('|');
- Dye *d = nullptr;
- if (p != std::string::npos)
- {
- d = new Dye(path.substr(p + 1));
- path = path.substr(0, p);
- }
-
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(path);
- if (rw != nullptr)
- {
- Image *const image = d != nullptr ?
- surfaceImageHelper->load(rw, *d)
- : surfaceImageHelper->load(rw);
-
- if (image != nullptr)
- {
- image->mIdPath = str;
-#ifdef DEBUG_IMAGES
- logger->log("set name %p, %s", static_cast<void*>(image),
- image->mIdPath.c_str());
-#endif // DEBUG_IMAGES
-
- images.push_back(image);
- }
- }
- delete d;
- }
- BLOCK_END("AtlasManager::loadImages")
-}
-
-void AtlasManager::loadEmptyImages(const StringVect &files,
- STD_VECTOR<Image*> &images)
-{
- BLOCK_START("AtlasManager::loadEmptyImages")
-
- FOR_EACH (StringVectCIter, it, files)
- {
- const std::string str = *it;
- // check is image with same name already in cache
- // and if yes, move it to deleted set
- Resource *const res = ResourceManager::getTempResource(str);
- if (res != nullptr)
- {
- // increase counter because in moveToDeleted it will be decreased.
- res->incRef();
- ResourceManager::moveToDeleted(res);
- }
-
- Image *const image = new Image(0,
- 2048, 2048,
- 2048, 2048);
- image->mIdPath = str;
- images.push_back(image);
- }
- BLOCK_END("AtlasManager::loadEmptyImages")
-}
-
-void AtlasManager::simpleSort(const std::string &restrict name,
- STD_VECTOR<TextureAtlas*> &restrict atlases,
- const STD_VECTOR<Image*> &restrict images,
- int size)
-{
- BLOCK_START("AtlasManager::simpleSort")
- int x = 0;
- int y = 0;
- int tempHeight = 0;
- TextureAtlas *atlas = new TextureAtlas;
- STD_VECTOR<Image*>::const_iterator it = images.begin();
- const STD_VECTOR<Image*>::const_iterator it_end = images.end();
- for (it = images.begin(); it != it_end; ++ it)
- {
- const Image *const img = *it;
- if (img != nullptr)
- {
- atlas->name = std::string("atlas_").append(name).append(
- "_").append(img->mIdPath);
- break;
- }
- }
-
- for (it = images.begin(); it != it_end; ++ it)
- {
- Image *const img = *it;
- if (img != nullptr)
- {
- AtlasItem *const item = new AtlasItem(img);
- item->name = img->mIdPath;
- // start next line
- if (x + img->mBounds.w > size)
- {
- x = 0;
- y += tempHeight;
- tempHeight = 0;
- }
-
- // can't put image with this height
- if (y + img->mBounds.h > size)
- {
- x = 0;
- y = 0;
- atlases.push_back(atlas);
- atlas = new TextureAtlas;
- atlas->name = std::string("atlas_").append(name).append(
- "_").append(img->mIdPath);
- }
-
- if (img->mBounds.h > tempHeight)
- tempHeight = img->mBounds.h;
-
- item->x = x;
- item->y = y;
- atlas->items.push_back(item);
-
- // continue put textures in line
- x += img->mBounds.w;
- if (x > atlas->width)
- atlas->width = x;
- if (y + img->mBounds.h > atlas->height)
- atlas->height = y + img->mBounds.h;
- }
- }
- if (!atlas->items.empty())
- atlases.push_back(atlas);
- else
- delete atlas;
- BLOCK_END("AtlasManager::simpleSort")
-}
-
-void AtlasManager::emptySort(const std::string &restrict name,
- STD_VECTOR<TextureAtlas*> &restrict atlases,
- const STD_VECTOR<Image*> &restrict images)
-{
- BLOCK_START("AtlasManager::simpleSort")
- TextureAtlas *atlas = new TextureAtlas;
- STD_VECTOR<Image*>::const_iterator it = images.begin();
- const STD_VECTOR<Image*>::const_iterator it_end = images.end();
- for (it = images.begin(); it != it_end; ++ it)
- {
- const Image *const img = *it;
- if (img != nullptr)
- {
- atlas->name = std::string("atlas_").append(name).append(
- "_").append(img->mIdPath);
- break;
- }
- }
-
- for (it = images.begin(); it != it_end; ++ it)
- {
- Image *const img = *it;
- if (img != nullptr)
- {
- AtlasItem *const item = new AtlasItem(img);
- item->name = img->mIdPath;
- item->x = 0;
- item->y = 0;
- atlas->items.push_back(item);
- }
- }
- if (!atlas->items.empty())
- atlases.push_back(atlas);
- else
- delete atlas;
- BLOCK_END("AtlasManager::simpleSort")
-}
-
-void AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
-{
- BLOCK_START("AtlasManager::createSDLAtlas")
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int rmask = 0xff000000;
- const unsigned int gmask = 0x00ff0000;
- const unsigned int bmask = 0x0000ff00;
- const unsigned int amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int rmask = 0x000000ff;
- const unsigned int gmask = 0x0000ff00;
- const unsigned int bmask = 0x00ff0000;
- const unsigned int amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- // do not create atlas based on only one image
- if (atlas->items.size() == 1)
- {
- logger->log("Skip atlas creation because only one image in atlas.");
- BLOCK_END("AtlasManager::createSDLAtlas")
- return;
- }
-
- // using only power of two sizes.
- atlas->width = powerOfTwo(atlas->width);
- atlas->height = powerOfTwo(atlas->height);
-
- const int width = atlas->width;
- const int height = atlas->height;
- BLOCK_START("AtlasManager::createSDLAtlas create surface")
- // temp SDL surface for atlas
- SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE,
- width, height, 32U, rmask, gmask, bmask, amask);
- if (surface == nullptr)
- {
- reportAlways("Error creating surface for atlas. Size: %dx%d",
- width,
- height);
- BLOCK_END("AtlasManager::createSDLAtlas")
- return;
- }
- BLOCK_END("AtlasManager::createSDLAtlas create surface")
-
-#ifdef OPENGLERRORS
- logger->log("OpenGL debug: creating atlase %dx%d", width, height);
-#endif // OPENGLERRORS
-
- Image *image = imageHelper->loadSurface(surface);
- // free SDL atlas surface
- MSDL_FreeSurface(surface);
- if (image == nullptr)
- {
- reportAlways("Error converting surface to texture. Size: %dx%d",
- width,
- height);
- return;
- }
-
- // drawing SDL images to surface
- FOR_EACH (STD_VECTOR<AtlasItem*>::iterator, it, atlas->items)
- {
- AtlasItem *const item = *it;
- imageHelper->copySurfaceToImage(image, item->x, item->y,
- item->image->mSDLSurface);
-#ifdef OPENGLERRORS
- logger->log("OpenGL debug: put atlas image %s (size %dx%d),"
- " into %d,%d to %d,%d",
- item->name.c_str(),
- item->image->mSDLSurface->w,
- item->image->mSDLSurface->h,
- item->x,
- item->y,
- item->x + item->image->mSDLSurface->w - 1,
- item->y + item->image->mSDLSurface->h - 1);
- if (item->x >= width)
- logger->log("OpenGL error: start x position outside of atlas");
- if (item->y >= height)
- logger->log("OpenGL error: start y position outside of atlas");
- if (item->x + item->image->mSDLSurface->w - 1 >= width)
- logger->log("OpenGL error: end x position outside of atlas");
- if (item->y + item->image->mSDLSurface->h - 1 >= height)
- logger->log("OpenGL error: end y position outside of atlas");
-#endif // OPENGLERRORS
- }
- atlas->atlasImage = image;
- BLOCK_END("AtlasManager::createSDLAtlas")
-}
-
-void AtlasManager::convertEmptyAtlas(TextureAtlas *const atlas)
-{
- // no check for null pointer in atlas because it was in caller
- // convert surface to OpemGL image
- Image *const oldImage = atlas->atlasImage;
-
- if (oldImage->mSDLSurface != nullptr)
- {
- atlas->atlasImage = imageHelper->loadSurface(
- atlas->atlasImage->mSDLSurface);
- oldImage->decRef();
- }
-
- Image *const image = atlas->atlasImage;
- if (image == nullptr)
- return;
-
- image->mIdPath = atlas->name;
-#ifdef DEBUG_IMAGES
- logger->log("set name %p, %s", static_cast<void*>(image),
- image->mIdPath.c_str());
-#endif // DEBUG_IMAGES
-
- image->incRef();
-
- FOR_EACH (STD_VECTOR<AtlasItem*>::iterator, it, atlas->items)
- {
- AtlasItem *const item = *it;
- // delete SDL Image
- delete item->image;
- // store OpenGL image
- item->image = image->getSubImage(item->x, item->y,
- item->width, item->height);
- Image *const image2 = item->image;
- if (image2 != nullptr)
- {
- image2->mIdPath = item->name;
-#ifdef DEBUG_IMAGES
- logger->log("set empty name %p, %s", static_cast<void*>(image2),
- image2->mIdPath.c_str());
-#endif // DEBUG_IMAGES
-
- image2->incRef();
- }
- }
-}
-
-void AtlasManager::convertAtlas(TextureAtlas *const atlas)
-{
- // no check for null pointer in atlas because it was in caller
- // convert surface to OpemGL image
- Image *const oldImage = atlas->atlasImage;
-
- if (oldImage->mSDLSurface != nullptr)
- {
- atlas->atlasImage = imageHelper->loadSurface(
- atlas->atlasImage->mSDLSurface);
- oldImage->decRef();
- }
-
- Image *const image = atlas->atlasImage;
- if (image == nullptr)
- return;
-
- image->mIdPath = atlas->name;
-#ifdef DEBUG_IMAGES
- logger->log("set name %p, %s", static_cast<void*>(image),
- image->mIdPath.c_str());
-#endif // DEBUG_IMAGES
-
- image->incRef();
-
- FOR_EACH (STD_VECTOR<AtlasItem*>::iterator, it, atlas->items)
- {
- AtlasItem *const item = *it;
- // delete SDL Image
- delete item->image;
- // store OpenGL image
- item->image = image->getSubImage(item->x, item->y,
- item->width, item->height);
- Image *const image2 = item->image;
- if (image2 != nullptr)
- {
- image2->mIdPath = item->name;
-#ifdef DEBUG_IMAGES
- logger->log("set name %p, %s", static_cast<void*>(image2),
- image2->mIdPath.c_str());
-#endif // DEBUG_IMAGES
-
- image2->incRef();
- }
- }
-}
-
-void AtlasManager::injectToResources(const AtlasResource *const resource)
-{
- if (resource == nullptr)
- return;
- FOR_EACH (STD_VECTOR<TextureAtlas*>::const_iterator,
- it, resource->atlases)
- {
- // add each atlas image to resources
- TextureAtlas *const atlas = *it;
- if (atlas != nullptr)
- {
- Image *const image = atlas->atlasImage;
- if (image != nullptr)
- ResourceManager::addResource(atlas->name, image);
- FOR_EACH (STD_VECTOR<AtlasItem*>::iterator, it2, atlas->items)
- {
- AtlasItem *const item = *it2;
- if (item == nullptr)
- continue;
- // add each atlas sub image to resources
- ResourceManager::addResource(item->name, item->image);
- }
- }
- }
-}
-
-void AtlasManager::moveToDeleted(AtlasResource *const resource)
-{
- if (resource == nullptr)
- return;
- FOR_EACH (STD_VECTOR<TextureAtlas*>::iterator, it, resource->atlases)
- {
- // move each atlas image to deleted
- TextureAtlas *const atlas = *it;
- if (atlas != nullptr)
- {
- Image *const image = atlas->atlasImage;
- if (image != nullptr)
- {
- // move each atlas image to deleted
- ResourceManager::moveToDeleted(image);
- }
- FOR_EACH (STD_VECTOR<AtlasItem*>::iterator, it2, atlas->items)
- {
- AtlasItem *const item = *it2;
- if (item != nullptr)
- {
- Image *const image2 = item->image;
- if (image2 != nullptr)
- {
- // move each atlas sub image to deleted
- ResourceManager::moveToDeleted(image2);
- }
- }
- }
- }
- }
-}
-
-#endif // USE_OPENGL
diff --git a/src/resources/atlas/atlasmanager.h b/src/resources/atlas/atlasmanager.h
deleted file mode 100644
index 4db0d1e4e..000000000
--- a/src/resources/atlas/atlasmanager.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ATLAS_ATLASMANAGER_H
-#define RESOURCES_ATLAS_ATLASMANAGER_H
-
-#ifdef USE_OPENGL
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-class AtlasResource;
-class Image;
-
-struct TextureAtlas;
-
-class AtlasManager final
-{
- public:
- AtlasManager() A_CONST;
-
- A_DELETE_COPY(AtlasManager)
-
- static AtlasResource *loadTextureAtlas(const std::string &name,
- const StringVect &files)
- A_WARN_UNUSED;
-
- static AtlasResource *loadEmptyAtlas(const std::string &name,
- const StringVect &files)
- A_WARN_UNUSED;
-
- static void injectToResources(const AtlasResource *const resource);
-
- static void moveToDeleted(AtlasResource *const resource);
-
- private:
- static void loadImages(const StringVect &files,
- STD_VECTOR<Image*> &images);
-
- static void loadEmptyImages(const StringVect &files,
- STD_VECTOR<Image*> &images);
-
- static void emptySort(const std::string &restrict name,
- STD_VECTOR<TextureAtlas*> &restrict atlases,
- const STD_VECTOR<Image*> &restrict images);
-
- static void simpleSort(const std::string &restrict name,
- STD_VECTOR<TextureAtlas*> &restrict atlases,
- const STD_VECTOR<Image*> &restrict images,
- int size);
-
- static void createSDLAtlas(TextureAtlas *const atlas) A_NONNULL(1);
-
- static void convertAtlas(TextureAtlas *const atlas) A_NONNULL(1);
-
- static void convertEmptyAtlas(TextureAtlas *const atlas) A_NONNULL(1);
-};
-
-#endif // USE_OPENGL
-#endif // RESOURCES_ATLAS_ATLASMANAGER_H
diff --git a/src/resources/atlas/atlasresource.cpp b/src/resources/atlas/atlasresource.cpp
deleted file mode 100644
index b97823ebb..000000000
--- a/src/resources/atlas/atlasresource.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "resources/atlas/atlasresource.h"
-
-#include "resources/atlas/atlasmanager.h"
-#include "resources/atlas/textureatlas.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-AtlasResource::~AtlasResource()
-{
- FOR_EACH (STD_VECTOR<TextureAtlas*>::iterator, it, atlases)
- {
- TextureAtlas *const atlas = *it;
- if (atlas != nullptr)
- {
- FOR_EACH (STD_VECTOR<AtlasItem*>::iterator, it2, atlas->items)
- {
- AtlasItem *const item = *it2;
- if (item != nullptr)
- {
- Image *const image2 = item->image;
- if (image2 != nullptr)
- image2->decRef();
- delete item;
- }
- }
- Image *const image = atlas->atlasImage;
- if (image != nullptr)
- image->decRef();
- delete atlas;
- }
- }
- ResourceManager::clearDeleted(false);
-}
-
-void AtlasResource::incRef()
-{
- if (mRefCount == 0u)
- AtlasManager::injectToResources(this);
- Resource::incRef();
-}
-
-void AtlasResource::decRef()
-{
- Resource::decRef();
- if (mRefCount == 0u)
- AtlasManager::moveToDeleted(this);
-}
-
-int AtlasResource::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(AtlasResource)) +
- Resource::calcMemoryLocal() +
- static_cast<int>(atlases.capacity() * sizeof(TextureAtlas*));
-}
-
-int AtlasResource::calcMemoryChilds(const int level) const
-{
- int sz = 0;
- FOR_EACH (STD_VECTOR<TextureAtlas*>::const_iterator, it, atlases)
- {
- TextureAtlas *const atlas = *it;
- sz += atlas->calcMemory(level + 1);
- }
- return sz;
-}
-
-#endif // USE_OPENGL
diff --git a/src/resources/atlas/atlasresource.h b/src/resources/atlas/atlasresource.h
deleted file mode 100644
index 60be25c1d..000000000
--- a/src/resources/atlas/atlasresource.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ATLAS_ATLASRESOURCE_H
-#define RESOURCES_ATLAS_ATLASRESOURCE_H
-
-#ifdef USE_OPENGL
-
-#include "utils/vector.h"
-
-#include "resources/resource.h"
-
-struct TextureAtlas;
-
-class AtlasResource final : public Resource
-{
- public:
- AtlasResource() :
- atlases()
- { }
-
- A_DELETE_COPY(AtlasResource)
-
- ~AtlasResource();
-
- void incRef() override final;
-
- void decRef() override final;
-
- int calcMemoryLocal() const override final;
-
- int calcMemoryChilds(const int level) const override final;
-
- STD_VECTOR<TextureAtlas*> atlases;
-};
-
-#endif // USE_OPENGL
-#endif // RESOURCES_ATLAS_ATLASRESOURCE_H
diff --git a/src/resources/atlas/textureatlas.h b/src/resources/atlas/textureatlas.h
deleted file mode 100644
index ff74049d5..000000000
--- a/src/resources/atlas/textureatlas.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ATLAS_TEXTUREATLAS_H
-#define RESOURCES_ATLAS_TEXTUREATLAS_H
-
-#ifdef USE_OPENGL
-
-#include "utils/foreach.h"
-#include "utils/stringvector.h"
-
-#include "resources/atlas/atlasitem.h"
-
-#include "localconsts.h"
-
-class AtlasResource;
-class Image;
-class Resource;
-
-struct AtlasItem;
-
-struct TextureAtlas final : public MemoryCounter
-{
- TextureAtlas() :
- MemoryCounter(),
- name(),
- atlasImage(nullptr),
- width(0),
- height(0),
- items()
- {
- }
-
- A_DELETE_COPY(TextureAtlas)
-
- int calcMemoryLocal() const override final
- {
- return static_cast<int>(sizeof(TextureAtlas) +
- items.capacity() * sizeof(AtlasItem*));
- }
-
- int calcMemoryChilds(const int level) const override final
- {
- int sz = 0;
- FOR_EACH (STD_VECTOR<AtlasItem*>::const_iterator, it, items)
- {
- AtlasItem *const item = *it;
- sz += item->calcMemory(level + 1);
- }
- return sz;
- }
-
- std::string getCounterName() const override
- { return name; }
-
- std::string name;
- Image *atlasImage;
- int width;
- int height;
- STD_VECTOR <AtlasItem*> items;
-};
-
-#endif // USE_OPENGL
-#endif // RESOURCES_ATLAS_TEXTUREATLAS_H
diff --git a/src/resources/attack.h b/src/resources/attack.h
deleted file mode 100644
index 90b3da9c3..000000000
--- a/src/resources/attack.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ATTACK_H
-#define RESOURCES_ATTACK_H
-
-#include "resources/missileinfo.h"
-
-struct Attack final
-{
- std::string mAction;
- std::string mSkyAction;
- std::string mWaterAction;
- std::string mRideAction;
- int mEffectId;
- int mHitEffectId;
- int mCriticalHitEffectId;
- int mMissEffectId;
- MissileInfo mMissile;
-
- Attack(const std::string &action,
- const std::string &skyAction,
- const std::string &waterAction,
- const std::string &rideAction,
- const int effectId,
- const int hitEffectId,
- const int criticalHitEffectId,
- const int missEffectId,
- const std::string &missileParticle,
- const float missileZ,
- const float missileSpeed,
- const float missileDieDistance,
- const int missileLifeTime) :
- mAction(action),
- mSkyAction(skyAction),
- mWaterAction(waterAction),
- mRideAction(rideAction),
- mEffectId(effectId),
- mHitEffectId(hitEffectId),
- mCriticalHitEffectId(criticalHitEffectId),
- mMissEffectId(missEffectId),
- mMissile()
- {
- mMissile.particle = missileParticle;
- mMissile.z = missileZ;
- mMissile.speed = missileSpeed;
- mMissile.dieDistance = missileDieDistance;
- mMissile.lifeTime = missileLifeTime;
- }
-
- A_DELETE_COPY(Attack)
-};
-
-#endif // RESOURCES_ATTACK_H
diff --git a/src/resources/basicstat.h b/src/resources/basicstat.h
deleted file mode 100644
index 7da925b92..000000000
--- a/src/resources/basicstat.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_BASICSTAT_H
-#define RESOURCES_BASICSTAT_H
-
-#include "enums/being/attributes.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct BasicStat final
-{
- BasicStat(const AttributesT attr0,
- const std::string &tag0,
- const std::string &name0) :
- tag(tag0),
- name(name0),
- attr(attr0)
- {}
-
- A_DEFAULT_COPY(BasicStat)
-
- std::string tag;
- std::string name;
- AttributesT attr;
-};
-
-#endif // RESOURCES_BASICSTAT_H
diff --git a/src/resources/beingcommon.cpp b/src/resources/beingcommon.cpp
deleted file mode 100644
index 441b1ee7c..000000000
--- a/src/resources/beingcommon.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/beingcommon.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "enums/resources/map/blockmask.h"
-
-#include "utils/cast.h"
-
-#include "resources/beinginfo.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "debug.h"
-
-void BeingCommon::readBasicAttributes(BeingInfo *const info,
- XmlNodePtrConst node,
- const std::string &hoverCursor)
-{
- info->setTargetCursorSize(XML::getProperty(node,
- "targetCursor", "medium"));
-
- info->setHoverCursor(XML::getProperty(node, "hoverCursor", hoverCursor));
-
- info->setTargetOffsetX(XML::getProperty(node, "targetOffsetX", 0));
- info->setTargetOffsetY(XML::getProperty(node, "targetOffsetY", 0));
-
- info->setNameOffsetX(XML::getProperty(node, "nameOffsetX", 0));
- info->setNameOffsetY(XML::getProperty(node, "nameOffsetY", 0));
- info->setSortOffsetY(XML::getProperty(node, "sortOffsetY", 0));
-
- info->setHpBarOffsetX(XML::getProperty(node, "hpBarOffsetX", 0));
- info->setHpBarOffsetY(XML::getProperty(node, "hpBarOffsetY", 0));
-
- info->setQuickActionEffectId(XML::getProperty(node,
- "quickActionEffect", -1));
-}
-
-void BeingCommon::readWalkingAttributes(BeingInfo *const info,
- XmlNodePtrConst node,
- const int moreBlockFlags)
-{
- uint8_t block = 0;
- std::string walkStr = XML::getProperty(
- node, "walkType", "walk");
-
- const uint8_t allFlags = CAST_U8(
- BlockMask::GROUND |
- BlockMask::WALL |
- BlockMask::WATER |
- BlockMask::AIR |
- moreBlockFlags);
- StringVect tokens;
- splitToStringVector(tokens, walkStr, ',');
- FOR_EACH (StringVectCIter, it, tokens)
- {
- if (walkStr == "walk" || walkStr == "ground")
- block |= BlockMask::GROUND;
- else if (walkStr == "fly" || walkStr == "air")
- block |= BlockMask::GROUND | BlockMask::WATER | BlockMask::AIR;
- else if (walkStr == "all")
- block |= allFlags;
- else if (walkStr == "wall")
- block |= BlockMask::WALL;
- else if (walkStr == "monsterwall")
- block |= BlockMask::MONSTERWALL;
- else if (walkStr == "swim" || walkStr == "water")
- block |= BlockMask::WATER;
- else if (walkStr == "walkswim" || walkStr == "swimwalk") // legacy
- block |= BlockMask::GROUND | BlockMask::WATER;
- }
- info->setBlockWalkMask(CAST_U8(block ^ allFlags));
-}
-
-void BeingCommon::readAiAttributes(BeingInfo *const info,
- XmlNodePtrConst node)
-{
- info->setStartFollowDist(XML::getProperty(node,
- "startFollowDistance", 3));
- info->setFollowDist(XML::getProperty(node,
- "followDistance", 0));
- info->setWarpDist(XML::getProperty(node,
- "warpDistance", 11));
-
- info->setTargetOffsetX(XML::getProperty(node,
- "offsetX", 0));
- info->setTargetOffsetY(XML::getProperty(node,
- "offsetY", 1));
- info->setSitOffsetX(XML::getProperty(node,
- "sitOffsetX", 0));
- info->setSitOffsetY(XML::getProperty(node,
- "sitOffsetY", 1));
- info->setMoveOffsetX(XML::getProperty(node,
- "moveOffsetX", 0));
- info->setMoveOffsetY(XML::getProperty(node,
- "moveOffsetY", 1));
- info->setDeadOffsetX(XML::getProperty(node,
- "deadOffsetX", 0));
- info->setDeadOffsetY(XML::getProperty(node,
- "deadOffsetY", 1));
- info->setAttackOffsetX(XML::getProperty(node,
- "attackOffsetX", info->getTargetOffsetX()));
- info->setAttackOffsetY(XML::getProperty(node,
- "attackOffsetY", info->getTargetOffsetY()));
-
- info->setThinkTime(XML::getProperty(node,
- "thinkTime", 500) / 10);
-
- info->setDirectionType(XML::getProperty(node,
- "directionType", 1));
- info->setSitDirectionType(XML::getProperty(node,
- "sitDirectionType", 1));
- info->setDeadDirectionType(XML::getProperty(node,
- "deadDirectionType", 1));
- info->setAttackDirectionType(XML::getProperty(node,
- "attackDirectionType", 4));
-}
-
-bool BeingCommon::readObjectNodes(XmlNodePtrConst &spriteNode,
- SpriteDisplay &display,
- BeingInfo *const currentInfo,
- const std::string &dbName)
-{
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- if (!XmlHaveChildContent(spriteNode))
- return true;
-
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
-
- currentSprite->variant = XML::getProperty(
- spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- return true;
- }
- else if (xmlNameEqual(spriteNode, "sound"))
- {
- if (!XmlHaveChildContent(spriteNode))
- return true;
-
- const std::string event = XML::getProperty(
- spriteNode, "event", "");
- const int delay = XML::getProperty(
- spriteNode, "delay", 0);
- const char *const filename = XmlChildContent(spriteNode);
-
- if (event == "hit")
- {
- currentInfo->addSound(ItemSoundEvent::HIT, filename, delay);
- }
- else if (event == "miss")
- {
- currentInfo->addSound(ItemSoundEvent::MISS, filename, delay);
- }
- else if (event == "hurt")
- {
- currentInfo->addSound(ItemSoundEvent::HURT, filename, delay);
- }
- else if (event == "die")
- {
- currentInfo->addSound(ItemSoundEvent::DIE, filename, delay);
- }
- else if (event == "move")
- {
- currentInfo->addSound(ItemSoundEvent::MOVE, filename, delay);
- }
- else if (event == "sit")
- {
- currentInfo->addSound(ItemSoundEvent::SIT, filename, delay);
- }
- else if (event == "sittop")
- {
- currentInfo->addSound(ItemSoundEvent::SITTOP, filename, delay);
- }
- else if (event == "spawn")
- {
- currentInfo->addSound(ItemSoundEvent::SPAWN, filename, delay);
- }
- else
- {
- logger->log((dbName + ": Warning, sound effect %s for "
- "unknown event %s of monster %s").c_str(),
- filename, event.c_str(),
- currentInfo->getName().c_str());
- }
- return true;
- }
- else if (xmlNameEqual(spriteNode, "attack"))
- {
- const int attackId = XML::getProperty(spriteNode, "id", 0);
- const int effectId = XML::getProperty(spriteNode, "effect-id",
- paths.getIntValue("effectId"));
- const int hitEffectId = XML::getProperty(spriteNode, "hit-effect-id",
- paths.getIntValue("hitEffectId"));
- const int criticalHitEffectId = XML::getProperty(spriteNode,
- "critical-hit-effect-id",
- paths.getIntValue("criticalHitEffectId"));
- const int missEffectId = XML::getProperty(spriteNode, "miss-effect-id",
- paths.getIntValue("missEffectId"));
-
- const std::string spriteAction = XML::getProperty(spriteNode, "action",
- "attack");
- const std::string skySpriteAction = XML::getProperty(spriteNode,
- "skyaction", "skyattack");
- const std::string waterSpriteAction = XML::getProperty(spriteNode,
- "wateraction", "waterattack");
- const std::string rideSpriteAction = XML::getProperty(spriteNode,
- "rideaction", "rideattack");
-
- const std::string missileParticle = XML::getProperty(spriteNode,
- "missile-particle", "");
-
- const float missileZ = XML::getFloatProperty(
- spriteNode, "missile-z", 32.0f);
- const int missileLifeTime = XML::getProperty(
- spriteNode, "missile-lifetime", 500);
- const float missileSpeed = XML::getFloatProperty(
- spriteNode, "missile-speed", 7.0f);
- const float missileDieDistance = XML::getFloatProperty(
- spriteNode, "missile-diedistance", 8.0f);
-
- currentInfo->addAttack(attackId,
- spriteAction,
- skySpriteAction,
- waterSpriteAction,
- rideSpriteAction,
- effectId,
- hitEffectId,
- criticalHitEffectId,
- missEffectId,
- missileParticle,
- missileZ,
- missileSpeed,
- missileDieDistance,
- missileLifeTime);
- return true;
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- if (!XmlHaveChildContent(spriteNode))
- return true;
-
- display.particles.push_back(XmlChildContent(spriteNode));
- return true;
- }
- return false;
-}
diff --git a/src/resources/beingcommon.h b/src/resources/beingcommon.h
deleted file mode 100644
index 5b58bf78d..000000000
--- a/src/resources/beingcommon.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_BEINGCOMMON_H
-#define RESOURCES_BEINGCOMMON_H
-
-#include "fs/virtfs/tools.h"
-
-#include "utils/foreach.h"
-#include "utils/xml.h"
-
-#include "localconsts.h"
-
-UTILS_FOREACH_H
-UTILS_VIRTFSTOOLS_H
-
-class BeingInfo;
-
-struct SpriteDisplay;
-
-#define loadXmlDir(name, function) \
- { \
- StringVect listVect; \
- VirtFs::getFilesInDir(paths.getStringValue( \
- name), listVect, ".xml"); \
- FOR_EACH (StringVectCIter, itVect, listVect) \
- { \
- function(*itVect, SkipError_true); \
- } \
- }
-
-#define loadXmlDir2(name, function, ext, skipError) \
- { \
- StringVect listVect; \
- VirtFs::getFilesInDir(name, listVect, ext); \
- FOR_EACH (StringVectCIter, itVect, listVect) \
- { \
- function(*itVect, skipError); \
- } \
- }
-
-namespace BeingCommon
-{
- void readBasicAttributes(BeingInfo *const info,
- XmlNodePtrConst node,
- const std::string &hoverCursor) A_NONNULL(1);
-
- void readWalkingAttributes(BeingInfo *const info,
- XmlNodePtrConst node,
- const int moreBlockFlags) A_NONNULL(1);
-
- void readAiAttributes(BeingInfo *const info,
- XmlNodePtrConst node);
-
- void getIncludeFiles(const std::string &dir,
- StringVect &list,
- const std::string &ext);
-
- bool readObjectNodes(XmlNodePtrConst &spriteNode,
- SpriteDisplay &display,
- BeingInfo *const currentInfo,
- const std::string &dbName) A_NONNULL(3);
-} // namespace BeingCommon
-
-#endif // RESOURCES_BEINGCOMMON_H
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
deleted file mode 100644
index 6c082d85f..000000000
--- a/src/resources/beinginfo.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/beinginfo.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "enums/resources/map/blockmask.h"
-
-#include "resources/attack.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "resources/db/colordb.h"
-
-#include "utils/cast.h"
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-BeingInfo *BeingInfo::unknown = nullptr;
-Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK,
- SpriteAction::ATTACKSKY,
- SpriteAction::ATTACKWATER,
- SpriteAction::ATTACKRIDE,
- -1,
- -1,
- -1,
- -1,
- std::string(),
- 32.0F,
- 7.0F,
- 8.0F,
- 500);
-
-BeingInfo::BeingInfo() :
- mDisplay(),
- // TRANSLATORS: being info default name
- mName(_("unnamed")),
- mTargetCursorSize(TargetCursorSize::MEDIUM),
- mHoverCursor(Cursor::CURSOR_POINTER),
- mSounds(),
- mAttacks(),
- mMenu(),
- mStrings(),
- mCurrency(),
- mBlockWalkMask(BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::MONSTERWALL),
- mBlockType(BlockType::NONE),
- mColors(nullptr),
- mTargetOffsetX(0),
- mTargetOffsetY(0),
- mNameOffsetX(0),
- mNameOffsetY(0),
- mHpBarOffsetX(0),
- mHpBarOffsetY(0),
- mMaxHP(0),
- mSortOffsetY(0),
- mDeadSortOffsetY(31),
- mAvatarId(BeingTypeId_zero),
- mWidth(0),
- mHeight(0),
- mStartFollowDist(3),
- mFollowDist(1),
- mWarpDist(11),
- mWalkSpeed(0),
- mSitOffsetX(0),
- mSitOffsetY(0),
- mMoveOffsetX(0),
- mMoveOffsetY(0),
- mDeadOffsetX(0),
- mDeadOffsetY(0),
- mAttackOffsetX(0),
- mAttackOffsetY(0),
- mThinkTime(50),
- mDirectionType(1),
- mSitDirectionType(1),
- mDeadDirectionType(1),
- mAttackDirectionType(1),
- mQuickActionEffectId(-1),
- mStaticMaxHP(false),
- mTargetSelection(true),
- mAllowDelete(true)
-{
- SpriteDisplay display;
- display.sprites.push_back(SpriteReference::Empty);
-
- setDisplay(display);
-}
-
-BeingInfo::~BeingInfo()
-{
- delete_all(mSounds);
- delete_all(mAttacks);
- mSounds.clear();
- delete_all(mDisplay.sprites);
-}
-
-void BeingInfo::setDisplay(const SpriteDisplay &display)
-{
- mDisplay = display;
-}
-
-void BeingInfo::setTargetCursorSize(const std::string &size)
-{
- if (size == "small")
- {
- setTargetCursorSize(TargetCursorSize::SMALL);
- }
- else if (size == "medium")
- {
- setTargetCursorSize(TargetCursorSize::MEDIUM);
- }
- else if (size == "large")
- {
- setTargetCursorSize(TargetCursorSize::LARGE);
- }
- else
- {
- logger->log("Unknown target cursor type \"%s\" for %s - using medium "
- "sized one", size.c_str(), getName().c_str());
- setTargetCursorSize(TargetCursorSize::MEDIUM);
- }
-}
-
-void BeingInfo::addSound(const ItemSoundEvent::Type event,
- const std::string &filename,
- const int delay)
-{
- if (mSounds.find(event) == mSounds.end())
- mSounds[event] = new SoundInfoVect;
-
- if (mSounds[event] != nullptr)
- mSounds[event]->push_back(SoundInfo(filename, delay));
-}
-
-const SoundInfo &BeingInfo::getSound(const ItemSoundEvent::Type event) const
-{
- static SoundInfo emptySound("", 0);
-
- const ItemSoundEvents::const_iterator i = mSounds.find(event);
-
- if (i == mSounds.end())
- return emptySound;
-
- const SoundInfoVect *const vect = i->second;
- if (vect == nullptr || vect->empty())
- return emptySound;
- return vect->at(CAST_SIZE(rand()) % vect->size());
-}
-
-const Attack *BeingInfo::getAttack(const int id) const
-{
- const Attacks::const_iterator i = mAttacks.find(id);
- return (i == mAttacks.end()) ? empty : (*i).second;
-}
-
-void BeingInfo::addAttack(const int id,
- const std::string &action,
- const std::string &skyAction,
- const std::string &waterAction,
- const std::string &rideAction,
- const int effectId,
- const int hitEffectId,
- const int criticalHitEffectId,
- const int missEffectId,
- const std::string &missileParticle,
- const float missileZ,
- const float missileSpeed,
- const float missileDieDistance,
- const int missileLifeTime)
-{
- delete mAttacks[id];
- mAttacks[id] = new Attack(action,
- skyAction,
- waterAction,
- rideAction,
- effectId,
- hitEffectId,
- criticalHitEffectId,
- missEffectId,
- missileParticle,
- missileZ,
- missileSpeed,
- missileDieDistance,
- missileLifeTime);
-}
-
-void BeingInfo::clear()
-{
- delete2(unknown);
- delete2(empty);
-}
-
-void BeingInfo::init()
-{
- if (empty != nullptr)
- {
- empty->mEffectId = paths.getIntValue("effectId");
- empty->mHitEffectId = paths.getIntValue("hitEffectId");
- empty->mCriticalHitEffectId = paths.getIntValue("criticalHitEffectId");
- empty->mMissEffectId = paths.getIntValue("missEffectId");
- }
-}
-
-void BeingInfo::setColorsList(const std::string &name)
-{
- if (name.empty())
- mColors = nullptr;
- else
- mColors = ColorDB::getColorsList(name);
-}
-
-std::string BeingInfo::getColor(const ItemColor idx) const
-{
- if (mColors == nullptr)
- return std::string();
-
- const std::map <ItemColor, ItemColorData>::const_iterator
- it = mColors->find(idx);
- if (it == mColors->end())
- return std::string();
- return it->second.color;
-}
-
-void BeingInfo::addMenu(const std::string &name, const std::string &command)
-{
- mMenu.push_back(BeingMenuItem(name, command));
-}
-
-const STD_VECTOR<BeingMenuItem> &BeingInfo::getMenu() const
-{
- return mMenu;
-}
-
-std::string BeingInfo::getString(const int idx) const
-{
- const std::map<int, std::string>::const_iterator it = mStrings.find(idx);
- if (it == mStrings.end())
- return "";
- return (*it).second;
-}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
deleted file mode 100644
index bd60131c8..000000000
--- a/src/resources/beinginfo.h
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_BEINGINFO_H
-#define RESOURCES_BEINGINFO_H
-
-#include "enums/being/targetcursorsize.h"
-
-#include "enums/resources/map/blocktype.h"
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "resources/beingmenuitem.h"
-#include "resources/cursors.h"
-#include "resources/soundinfo.h"
-
-#include "resources/sprite/spritedisplay.h"
-
-struct Attack;
-
-class ItemColorData;
-
-typedef std::map<int, Attack*> Attacks;
-
-/**
- * Holds information about a certain type of monster. This includes the name
- * of the monster, the sprite to display and the sounds the monster makes.
- *
- * @see MonsterDB
- * @see NPCDB
- */
-class BeingInfo final
-{
- public:
- static BeingInfo *unknown;
- static Attack *empty;
-
- BeingInfo();
-
- A_DELETE_COPY(BeingInfo)
-
- ~BeingInfo();
-
- void setName(const std::string &name)
- { mName = name; }
-
- const std::string &getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- void setDisplay(const SpriteDisplay &display);
-
- const SpriteDisplay &getDisplay() const noexcept2 A_WARN_UNUSED
- { return mDisplay; }
-
- void setTargetCursorSize(const std::string &size);
-
- void setTargetCursorSize(const TargetCursorSizeT &targetSize)
- { mTargetCursorSize = targetSize; }
-
- void setHoverCursor(const std::string &name)
- { return setHoverCursor(Cursors::stringToCursor(name)); }
-
- void setHoverCursor(const CursorT &cursor)
- { mHoverCursor = cursor; }
-
- CursorT getHoverCursor() const noexcept2 A_WARN_UNUSED
- { return mHoverCursor; }
-
- TargetCursorSizeT getTargetCursorSize() const noexcept2 A_WARN_UNUSED
- { return mTargetCursorSize; }
-
- void addSound(const ItemSoundEvent::Type event,
- const std::string &filename,
- const int delay);
-
- const SoundInfo &getSound(const ItemSoundEvent::Type event)
- const A_WARN_UNUSED;
-
- void addAttack(const int id,
- const std::string &action,
- const std::string &skyAttack,
- const std::string &waterAttack,
- const std::string &rideAttack,
- const int effectId,
- const int hitEffectId,
- const int criticalHitEffectId,
- const int missEffectId,
- const std::string &missileParticle,
- const float missileZ,
- const float missileSpeed,
- const float missileDieDistance,
- const int missileLifeTime);
-
- const Attack *getAttack(const int id) const A_WARN_UNUSED;
-
- void setBlockWalkMask(const unsigned char mask)
- { mBlockWalkMask = mask; }
-
- /**
- * Gets the way the being is blocked by other objects
- */
- unsigned char getBlockWalkMask() const noexcept2 A_WARN_UNUSED
- { return mBlockWalkMask; }
-
- void setBlockType(const BlockTypeT &blockType)
- { mBlockType = blockType; }
-
- BlockTypeT getBlockType() const noexcept2 A_WARN_UNUSED
- { return mBlockType; }
-
- void setTargetOffsetX(const int n)
- { mTargetOffsetX = n; }
-
- int getTargetOffsetX() const noexcept2 A_WARN_UNUSED
- { return mTargetOffsetX; }
-
- void setTargetOffsetY(const int n)
- { mTargetOffsetY = n; }
-
- int getTargetOffsetY() const noexcept2 A_WARN_UNUSED
- { return mTargetOffsetY; }
-
- void setNameOffsetX(const int n)
- { mNameOffsetX = n; }
-
- int getNameOffsetX() const noexcept2 A_WARN_UNUSED
- { return mNameOffsetX; }
-
- void setNameOffsetY(const int n)
- { mNameOffsetY = n; }
-
- int getNameOffsetY() const noexcept2 A_WARN_UNUSED
- { return mNameOffsetY; }
-
- void setHpBarOffsetX(const int n)
- { mHpBarOffsetX = n; }
-
- int getHpBarOffsetX() const noexcept2 A_WARN_UNUSED
- { return mHpBarOffsetX; }
-
- void setHpBarOffsetY(const int n)
- { mHpBarOffsetY = n; }
-
- int getHpBarOffsetY() const noexcept2 A_WARN_UNUSED
- { return mHpBarOffsetY; }
-
- void setMaxHP(const int n)
- { mMaxHP = n; }
-
- int getMaxHP() const noexcept2 A_WARN_UNUSED
- { return mMaxHP; }
-
- bool isStaticMaxHP() const noexcept2 A_WARN_UNUSED
- { return mStaticMaxHP; }
-
- void setStaticMaxHP(const bool n)
- { mStaticMaxHP = n; }
-
- void setTargetSelection(const bool n)
- { mTargetSelection = n; }
-
- bool isTargetSelection() const noexcept2 A_WARN_UNUSED
- { return mTargetSelection; }
-
- int getSortOffsetY() const noexcept2 A_WARN_UNUSED
- { return mSortOffsetY; }
-
- void setSortOffsetY(const int n)
- { mSortOffsetY = n; }
-
- int getDeadSortOffsetY() const noexcept2 A_WARN_UNUSED
- { return mDeadSortOffsetY; }
-
- void setDeadSortOffsetY(const int n)
- { mDeadSortOffsetY = n; }
-
- BeingTypeId getAvatarId() const noexcept2 A_WARN_UNUSED
- { return mAvatarId; }
-
- void setAvatarId(const BeingTypeId id)
- { mAvatarId = id; }
-
- int getWidth() const noexcept2 A_WARN_UNUSED
- { return mWidth; }
-
- int getHeight() const noexcept2 A_WARN_UNUSED
- { return mHeight; }
-
- void setWidth(const int n)
- { mWidth = n; }
-
- void setHeight(const int n)
- { mHeight = n; }
-
- void setStartFollowDist(const int n)
- { mStartFollowDist = n; }
-
- int getStartFollowDist() const noexcept2 A_WARN_UNUSED
- { return mStartFollowDist; }
-
- void setFollowDist(const int n)
- { mFollowDist = n; }
-
- int getFollowDist() const noexcept2 A_WARN_UNUSED
- { return mFollowDist; }
-
- void setWalkSpeed(const int n)
- { mWalkSpeed = n; }
-
- int getWalkSpeed() const noexcept2 A_WARN_UNUSED
- { return mWalkSpeed; }
-
- void setWarpDist(const int n)
- { mWarpDist = n; }
-
- int getWarpDist() const noexcept2 A_WARN_UNUSED
- { return mWarpDist; }
-
- void setSitOffsetX(const int n)
- { mSitOffsetX = n; }
-
- int getSitOffsetX() const noexcept2 A_WARN_UNUSED
- { return mSitOffsetX; }
-
- void setSitOffsetY(const int n)
- { mSitOffsetY = n; }
-
- int getSitOffsetY() const noexcept2 A_WARN_UNUSED
- { return mSitOffsetY; }
-
- void setMoveOffsetX(const int n)
- { mMoveOffsetX = n; }
-
- int getMoveOffsetX() const noexcept2 A_WARN_UNUSED
- { return mMoveOffsetX; }
-
- void setMoveOffsetY(const int n)
- { mMoveOffsetY = n; }
-
- int getMoveOffsetY() const noexcept2 A_WARN_UNUSED
- { return mMoveOffsetY; }
-
- void setDeadOffsetX(const int n)
- { mDeadOffsetX = n; }
-
- int getDeadOffsetX() const noexcept2 A_WARN_UNUSED
- { return mDeadOffsetX; }
-
- void setDeadOffsetY(const int n)
- { mDeadOffsetY = n; }
-
- int getDeadOffsetY() const noexcept2 A_WARN_UNUSED
- { return mDeadOffsetY; }
-
- void setAttackOffsetX(const int n)
- { mAttackOffsetX = n; }
-
- int getAttackOffsetX() const noexcept2 A_WARN_UNUSED
- { return mAttackOffsetX; }
-
- void setAttackOffsetY(const int n)
- { mAttackOffsetY = n; }
-
- int getAttackOffsetY() const noexcept2 A_WARN_UNUSED
- { return mAttackOffsetY; }
-
- void setThinkTime(const int n)
- { mThinkTime = n; }
-
- int getThinkTime() const noexcept2 A_WARN_UNUSED
- { return mThinkTime; }
-
- void setDirectionType(const int n)
- { mDirectionType = n; }
-
- int getDirectionType() const noexcept2 A_WARN_UNUSED
- { return mDirectionType; }
-
- void setSitDirectionType(const int n)
- { mSitDirectionType = n; }
-
- int getSitDirectionType() const noexcept2 A_WARN_UNUSED
- { return mSitDirectionType; }
-
- void setDeadDirectionType(const int n)
- { mDeadDirectionType = n; }
-
- int getDeadDirectionType() const noexcept2 A_WARN_UNUSED
- { return mDeadDirectionType; }
-
- void setAttackDirectionType(const int n)
- { mAttackDirectionType = n; }
-
- int getAttackDirectionType() const noexcept2 A_WARN_UNUSED
- { return mAttackDirectionType; }
-
- void setAllowDelete(const bool b)
- { mAllowDelete = b; }
-
- int getAllowDelete() const noexcept2 A_WARN_UNUSED
- { return static_cast<int>(mAllowDelete); }
-
- void setQuickActionEffectId(const int n)
- { mQuickActionEffectId = n; }
-
- int getQuickActionEffectId() const noexcept2 A_WARN_UNUSED
- { return mQuickActionEffectId; }
-
- void setColorsList(const std::string &name);
-
- std::string getColor(const ItemColor idx) const A_WARN_UNUSED;
-
- void addMenu(const std::string &name, const std::string &command);
-
- const STD_VECTOR<BeingMenuItem> &getMenu() const A_CONST;
-
- void setString(const int idx,
- const std::string &value)
- { mStrings[idx] = value; }
-
- std::string getString(const int idx) const A_WARN_UNUSED;
-
- std::string getCurrency() const A_WARN_UNUSED
- { return mCurrency; }
-
- void setCurrency(const std::string &name)
- { mCurrency = name; }
-
- static void init();
-
- static void clear();
-
- private:
- SpriteDisplay mDisplay;
- std::string mName;
- TargetCursorSizeT mTargetCursorSize;
- CursorT mHoverCursor;
- ItemSoundEvents mSounds;
- Attacks mAttacks;
- STD_VECTOR<BeingMenuItem> mMenu;
- std::map<int, std::string> mStrings;
- std::string mCurrency;
- unsigned char mBlockWalkMask;
- BlockTypeT mBlockType;
- const std::map <ItemColor, ItemColorData> *mColors;
- int mTargetOffsetX;
- int mTargetOffsetY;
- int mNameOffsetX;
- int mNameOffsetY;
- int mHpBarOffsetX;
- int mHpBarOffsetY;
- int mMaxHP;
- int mSortOffsetY;
- int mDeadSortOffsetY;
- BeingTypeId mAvatarId;
- int mWidth;
- int mHeight;
- int mStartFollowDist;
- int mFollowDist;
- int mWarpDist;
- int mWalkSpeed;
- int mSitOffsetX;
- int mSitOffsetY;
- int mMoveOffsetX;
- int mMoveOffsetY;
- int mDeadOffsetX;
- int mDeadOffsetY;
- int mAttackOffsetX;
- int mAttackOffsetY;
- int mThinkTime;
- int mDirectionType;
- int mSitDirectionType;
- int mDeadDirectionType;
- int mAttackDirectionType;
- int mQuickActionEffectId;
- bool mStaticMaxHP;
- bool mTargetSelection;
- bool mAllowDelete;
-};
-
-typedef std::map<BeingTypeId, BeingInfo*> BeingInfos;
-typedef BeingInfos::iterator BeingInfoIterator;
-
-#endif // RESOURCES_BEINGINFO_H
diff --git a/src/resources/beingmenuitem.h b/src/resources/beingmenuitem.h
deleted file mode 100644
index 2dfd23752..000000000
--- a/src/resources/beingmenuitem.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_BEINGMENUITEM_H
-#define RESOURCES_BEINGMENUITEM_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct BeingMenuItem final
-{
- BeingMenuItem(const std::string &name0,
- const std::string &command0) :
- name(name0),
- command(command0)
- {
- }
-
- A_DEFAULT_COPY(BeingMenuItem)
-
- std::string name;
- std::string command;
-};
-
-#endif // RESOURCES_BEINGMENUITEM_H
diff --git a/src/resources/beingslot.cpp b/src/resources/beingslot.cpp
deleted file mode 100644
index e6e008584..000000000
--- a/src/resources/beingslot.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/beingslot.h"
-
-#include "debug.h"
-
-BeingSlot *emptyBeingSlot = nullptr;
diff --git a/src/resources/beingslot.h b/src/resources/beingslot.h
deleted file mode 100644
index eb8a1f5f4..000000000
--- a/src/resources/beingslot.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_BEINGSLOT_H
-#define RESOURCES_BEINGSLOT_H
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "resources/item/cardslist.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct BeingSlot final
-{
- BeingSlot() :
- spriteId(0),
- cardsId(zeroCards),
- colorId(ItemColor_one),
- color()
- {
- }
-
- A_DEFAULT_COPY(BeingSlot)
-
- int spriteId;
- CardsList cardsId;
- ItemColor colorId;
- std::string color;
-};
-
-extern BeingSlot *emptyBeingSlot;
-
-#endif // RESOURCES_BEINGSLOT_H
diff --git a/src/resources/chatobject.cpp b/src/resources/chatobject.cpp
deleted file mode 100644
index c0ce7800d..000000000
--- a/src/resources/chatobject.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/chatobject.h"
-
-#include "debug.h"
-
-std::map<std::string, ChatObject*> ChatObject::chatNameMap;
-std::map<int, ChatObject*> ChatObject::chatIdMap;
-
-ChatObject::ChatObject() :
- ownerId(BeingId_zero),
- chatId(0),
- maxUsers(0),
- currentUsers(0),
- type(0),
- title()
-{
-}
-
-ChatObject::~ChatObject()
-{
- std::map<std::string, ChatObject*>::iterator it = chatNameMap.find(title);
- if (it != chatNameMap.end() && (*it).second == this)
- chatNameMap.erase(it);
- std::map<int, ChatObject*>::iterator it2 = chatIdMap.find(chatId);
- if (it2 != chatIdMap.end() && (*it2).second == this)
- chatIdMap.erase(it2);
-}
-
-void ChatObject::update()
-{
- chatNameMap[title] = this;
- chatIdMap[chatId] = this;
-}
-
-ChatObject *ChatObject::findByName(const std::string &name)
-{
- const std::map<std::string, ChatObject*>::iterator it =
- chatNameMap.find(name);
- if (it == chatNameMap.end())
- return nullptr;
- return (*it).second;
-}
-
-ChatObject *ChatObject::findById(const int id)
-{
- const std::map<int, ChatObject*>::iterator it = chatIdMap.find(id);
- if (it == chatIdMap.end())
- return nullptr;
- return (*it).second;
-}
diff --git a/src/resources/chatobject.h b/src/resources/chatobject.h
deleted file mode 100644
index f4371ec3c..000000000
--- a/src/resources/chatobject.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_CHATOBJECT_H
-#define RESOURCES_CHATOBJECT_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct ChatObject final
-{
- ChatObject();
-
- ~ChatObject();
-
- A_DELETE_COPY(ChatObject)
-
- void update();
-
- static ChatObject *findByName(const std::string &name);
-
- static ChatObject *findById(const int id);
-
- BeingId ownerId;
- int chatId;
- uint16_t maxUsers;
- uint16_t currentUsers;
- uint8_t type;
- std::string title;
-
- static std::map<std::string, ChatObject*> chatNameMap;
- static std::map<int, ChatObject*> chatIdMap;
-};
-
-#endif // RESOURCES_CHATOBJECT_H
diff --git a/src/resources/cursors.cpp b/src/resources/cursors.cpp
deleted file mode 100644
index a773cd5af..000000000
--- a/src/resources/cursors.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/cursors.h"
-
-#include "debug.h"
-
-namespace Cursors
-{
- static const StrToCursor hoverCursors[] =
- {
- {"select", Cursor::CURSOR_POINTER},
- {"pointer", Cursor::CURSOR_POINTER},
- {"lr", Cursor::CURSOR_RESIZE_ACROSS},
- {"rl", Cursor::CURSOR_RESIZE_ACROSS},
- {"resizeAcross", Cursor::CURSOR_RESIZE_ACROSS},
- {"ud", Cursor::CURSOR_RESIZE_DOWN},
- {"du", Cursor::CURSOR_RESIZE_DOWN},
- {"resizeDown", Cursor::CURSOR_RESIZE_DOWN},
- {"ldru", Cursor::CURSOR_RESIZE_DOWN_LEFT},
- {"ruld", Cursor::CURSOR_RESIZE_DOWN_LEFT},
- {"ld", Cursor::CURSOR_RESIZE_DOWN_LEFT},
- {"ru", Cursor::CURSOR_RESIZE_DOWN_LEFT},
- {"resizeDownLeft", Cursor::CURSOR_RESIZE_DOWN_LEFT},
- {"lurd", Cursor::CURSOR_RESIZE_DOWN_RIGHT},
- {"rdlu", Cursor::CURSOR_RESIZE_DOWN_RIGHT},
- {"rd", Cursor::CURSOR_RESIZE_DOWN_RIGHT},
- {"lu", Cursor::CURSOR_RESIZE_DOWN_RIGHT},
- {"resizeDownRight", Cursor::CURSOR_RESIZE_DOWN_RIGHT},
- {"attack", Cursor::CURSOR_FIGHT},
- {"fight", Cursor::CURSOR_FIGHT},
- {"take", Cursor::CURSOR_PICKUP},
- {"pickup", Cursor::CURSOR_PICKUP},
- {"talk", Cursor::CURSOR_TALK},
- {"action", Cursor::CURSOR_ACTION},
- {"left", Cursor::CURSOR_LEFT},
- {"up", Cursor::CURSOR_UP},
- {"right", Cursor::CURSOR_RIGHT},
- {"down", Cursor::CURSOR_DOWN}
- };
-
- CursorT stringToCursor(const std::string &name)
- {
- for (size_t f = 0; f < sizeof(hoverCursors) / sizeof(StrToCursor);
- f ++)
- {
- if (hoverCursors[f].str == name)
- return hoverCursors[f].cursor;
- }
- return Cursor::CURSOR_POINTER;
- }
-} // namespace Cursors
diff --git a/src/resources/cursors.h b/src/resources/cursors.h
deleted file mode 100644
index bf233fc0e..000000000
--- a/src/resources/cursors.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_CURSOR_H
-#define RESOURCES_CURSOR_H
-
-#include "enums/resources/cursor.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Cursors
-{
- struct StrToCursor final
- {
- A_DEFAULT_COPY(StrToCursor)
-
- std::string str;
- CursorT cursor;
- };
-
- CursorT stringToCursor(const std::string &name) A_WARN_UNUSED;
-} // namespace Cursors
-
-#endif // RESOURCES_CURSOR_H
diff --git a/src/resources/db/avatardb.cpp b/src/resources/db/avatardb.cpp
deleted file mode 100644
index cfa1a4517..000000000
--- a/src/resources/db/avatardb.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/avatardb.h"
-
-#include "logger.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "configuration.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mAvatarInfos;
- bool mLoaded = false;
-} // namespace
-
-void AvatarDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing avatar database...");
- loadXmlFile(paths.getStringValue("avatarsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("avatarsPatchFile"), SkipError_true);
- loadXmlDir("avatarsPatchDir", loadXmlFile);
-}
-
-void AvatarDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "avatars"))
- {
- logger->log("Avatars Database: Error while loading %s!",
- fileName.c_str());
- mLoaded = true;
- return;
- }
-
- for_each_xml_child_node(avatarNode, rootNode)
- {
- if (xmlNameEqual(avatarNode, "include"))
- {
- const std::string name = XML::getProperty(avatarNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (!xmlNameEqual(avatarNode, "avatar"))
- continue;
-
- const BeingTypeId id = fromInt(XML::getProperty(
- avatarNode, "id", 0), BeingTypeId);
- BeingInfo *currentInfo = nullptr;
- if (mAvatarInfos.find(id) != mAvatarInfos.end())
- currentInfo = mAvatarInfos[id];
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setName(XML::langProperty(
- // TRANSLATORS: unknown info name
- avatarNode, "name", _("unnamed")));
-
- currentInfo->setTargetOffsetX(XML::getProperty(avatarNode,
- "targetOffsetX", 0));
-
- currentInfo->setTargetOffsetY(XML::getProperty(avatarNode,
- "targetOffsetY", 0));
-
- currentInfo->setWidth(XML::getProperty(avatarNode,
- "width", 0));
- currentInfo->setHeight(XML::getProperty(avatarNode,
- "height", 0));
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, avatarNode)
- {
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant = XML::getProperty(
- spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- }
- currentInfo->setDisplay(display);
- mAvatarInfos[id] = currentInfo;
- }
-
- mLoaded = true;
-}
-
-void AvatarDB::unload()
-{
- logger->log1("Unloading avatar database...");
- delete_all(mAvatarInfos);
- mAvatarInfos.clear();
- mLoaded = false;
-}
-
-BeingInfo *AvatarDB::get(const BeingTypeId id)
-{
- const BeingInfoIterator i = mAvatarInfos.find(id);
- if (i == mAvatarInfos.end())
- return BeingInfo::unknown;
- return i->second;
-}
diff --git a/src/resources/db/avatardb.h b/src/resources/db/avatardb.h
deleted file mode 100644
index 537207a93..000000000
--- a/src/resources/db/avatardb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_AVATARDB_H
-#define RESOURCES_DB_AVATARDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class BeingInfo;
-
-namespace AvatarDB
-{
- void load();
-
- void unload();
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-} // namespace AvatarDB
-
-#endif // RESOURCES_DB_AVATARDB_H
diff --git a/src/resources/db/badgesdb.cpp b/src/resources/db/badgesdb.cpp
deleted file mode 100644
index 1d41ba1e5..000000000
--- a/src/resources/db/badgesdb.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/badgesdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "utils/foreach.h"
-#include "utils/xmlutils.h"
-
-#include "debug.h"
-
-namespace
-{
- BadgesInfos mGuilds;
- BadgesInfos mNames;
- BadgesInfos mParties;
- bool mLoaded = false;
-} // namespace
-
-static void loadXmlFile(const std::string &file,
- const std::string &name,
- BadgesInfos &arr,
- const SkipError skipError)
-{
- readXmlStringMap(file,
- "badges",
- name,
- "badge",
- "name",
- "image",
- arr,
- skipError);
-}
-
-static void loadDB(const std::string &name, BadgesInfos &arr)
-{
- loadXmlFile(paths.getStringValue("badgesFile"),
- name, arr, SkipError_false);
- loadXmlFile(paths.getStringValue("badgesPatchFile"),
- name, arr, SkipError_true);
-
- StringVect listVect;
- VirtFs::getFilesInDir(paths.getStringValue(
- "badgesPatchDir"),
- listVect,
- ".xml");
- FOR_EACH (StringVectCIter, itVect, listVect)
- loadXmlFile(*itVect, name, arr, SkipError_true);
-}
-
-void BadgesDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing Badges database...");
- loadDB("guild", mGuilds);
- loadDB("name", mNames);
- loadDB("party", mParties);
-}
-
-void BadgesDB::unload()
-{
- logger->log1("Unloading Badges database...");
- mParties.clear();
- mGuilds.clear();
- mNames.clear();
- mLoaded = false;
-}
-
-const std::string BadgesDB::getPartyBadge(const std::string &name)
-{
- const BadgesInfosIter it = mParties.find(name);
- if (it == mParties.end())
- return std::string();
- return (*it).second;
-}
-
-const std::string BadgesDB::getNameBadge(const std::string &name)
-{
- const BadgesInfosIter it = mNames.find(name);
- if (it == mNames.end())
- return std::string();
- return (*it).second;
-}
-
-const std::string BadgesDB::getGuildBadge(const std::string &name)
-{
- const BadgesInfosIter it = mGuilds.find(name);
- if (it == mGuilds.end())
- return std::string();
- return (*it).second;
-}
diff --git a/src/resources/db/badgesdb.h b/src/resources/db/badgesdb.h
deleted file mode 100644
index ca8ac631e..000000000
--- a/src/resources/db/badgesdb.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_BADGESDB_H
-#define RESOURCES_DB_BADGESDB_H
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-typedef std::map<std::string, std::string> BadgesInfos;
-typedef BadgesInfos::const_iterator BadgesInfosIter;
-
-namespace BadgesDB
-{
- void load();
-
- void unload();
-
- const std::string getGuildBadge(const std::string &name);
-
- const std::string getNameBadge(const std::string &name);
-
- const std::string getPartyBadge(const std::string &name);
-} // namespace BadgesDB
-
-#endif // RESOURCES_DB_BADGESDB_H
diff --git a/src/resources/db/chardb.cpp b/src/resources/db/chardb.cpp
deleted file mode 100644
index 2dd60270b..000000000
--- a/src/resources/db/chardb.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/chardb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- unsigned mMinHairColor = 0;
- unsigned mMaxHairColor = 0;
- unsigned mMinHairStyle = 0;
- unsigned mMaxHairStyle = 0;
- unsigned mMinStat = 0;
- unsigned mMaxStat = 0;
- unsigned mSumStat = 0;
- unsigned mMinLook = 0;
- unsigned mMaxLook = 0;
- unsigned mMinRace = 0;
- unsigned mMaxRace = 30;
- STD_VECTOR<BeingSlot> mDefaultItems;
-} // namespace
-
-void CharDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing char database...");
-
- XML::Document *doc = new XML::Document(
- paths.getStringValue("charCreationFile"),
- UseVirtFs_true,
- SkipError_false);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "chars"))
- {
- logger->log("CharDB: Failed to parse %s.",
- paths.getStringValue("charCreationFile").c_str());
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "haircolor"))
- {
- loadMinMax(node, &mMinHairColor, &mMaxHairColor);
- }
- else if (xmlNameEqual(node, "hairstyle"))
- {
- loadMinMax(node, &mMinHairStyle, &mMaxHairStyle);
- }
- else if (xmlNameEqual(node, "look"))
- {
- loadMinMax(node, &mMinLook, &mMaxLook);
- }
- else if (xmlNameEqual(node, "stat"))
- {
- loadMinMax(node, &mMinStat, &mMaxStat);
- mSumStat = XML::getProperty(node, "sum", 0);
- }
- else if (xmlNameEqual(node, "item"))
- {
- const int id = XML::getProperty(node, "id", 0);
- if (id > 0)
- {
- BeingSlot slot;
- slot.spriteId = id;
- for (int f = 0; f < maxCards; f ++)
- {
- const std::string cardName = strprintf("card%d", f + 1);
- slot.cardsId.cards[f] = XML::getProperty(node,
- cardName.c_str(),
- 0);
- }
- mDefaultItems.push_back(slot);
- }
- }
- else if (xmlNameEqual(node, "race"))
- {
- loadMinMax(node, &mMinRace, &mMaxRace);
- }
- }
-
- delete doc;
-
- mLoaded = true;
-}
-
-void CharDB::loadMinMax(XmlNodeConstPtr node,
- unsigned *restrict const min,
- unsigned *restrict const max)
-{
- if (min != nullptr)
- *min = XML::getProperty(node, "min", 1);
- if (max != nullptr)
- *max = XML::getProperty(node, "max", 10);
-}
-
-void CharDB::unload()
-{
- logger->log1("Unloading char database...");
-
- mLoaded = false;
-}
-
-unsigned CharDB::getMinHairColor()
-{
- return mMinHairColor;
-}
-
-unsigned CharDB::getMaxHairColor()
-{
- return mMaxHairColor;
-}
-
-unsigned CharDB::getMinHairStyle()
-{
- return mMinHairStyle;
-}
-
-unsigned CharDB::getMaxHairStyle()
-{
- return mMaxHairStyle;
-}
-
-unsigned CharDB::getMinStat()
-{
- return mMinStat;
-}
-
-unsigned CharDB::getMaxStat()
-{
- return mMaxStat;
-}
-
-unsigned CharDB::getSumStat()
-{
- return mSumStat;
-}
-
-unsigned CharDB::getMinLook()
-{
- return mMinLook;
-}
-
-unsigned CharDB::getMaxLook()
-{
- return mMaxLook;
-}
-
-unsigned CharDB::getMinRace()
-{
- return mMinRace;
-}
-
-unsigned CharDB::getMaxRace()
-{
- return mMaxRace;
-}
-
-const STD_VECTOR<BeingSlot> &CharDB::getDefaultItems()
-{
- return mDefaultItems;
-}
diff --git a/src/resources/db/chardb.h b/src/resources/db/chardb.h
deleted file mode 100644
index f940d3059..000000000
--- a/src/resources/db/chardb.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_CHARDB_H
-#define RESOURCES_DB_CHARDB_H
-
-#include "utils/xml.h"
-
-#include "utils/vector.h"
-
-#include "resources/beingslot.h"
-
-/**
- * Char information database.
- */
-namespace CharDB
-{
- /**
- * Loads the chars data.
- */
- void load();
-
- /**
- * Clear the chars data
- */
- void unload();
-
- void loadMinMax(XmlNodeConstPtr node,
- unsigned *restrict const min,
- unsigned *restrict const max);
-
- unsigned getMinHairColor() A_WARN_UNUSED;
-
- unsigned getMaxHairColor() A_WARN_UNUSED;
-
- unsigned getMinHairStyle() A_WARN_UNUSED;
-
- unsigned getMaxHairStyle() A_WARN_UNUSED;
-
- unsigned getMinStat() A_WARN_UNUSED;
-
- unsigned getMaxStat() A_WARN_UNUSED;
-
- unsigned getSumStat() A_WARN_UNUSED;
-
- unsigned getMinLook() A_WARN_UNUSED;
-
- unsigned getMaxLook() A_WARN_UNUSED;
-
- unsigned getMinRace() A_WARN_UNUSED;
-
- unsigned getMaxRace() A_WARN_UNUSED;
-
- const STD_VECTOR<BeingSlot> &getDefaultItems() A_WARN_UNUSED;
-} // namespace CharDB
-
-#endif // RESOURCES_DB_CHARDB_H
diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp
deleted file mode 100644
index 626ef78ae..000000000
--- a/src/resources/db/colordb.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/colordb.h"
-
-#include "configuration.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- int mHairColorsSize = 0;
- bool mLoaded = false;
- std::string mFail("#ffffff");
- ColorDB::ColorLists mColorLists;
-} // namespace
-
-void ColorDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing color database...");
-
- std::map<ItemColor, ItemColorData> colors;
- ColorListsIterator it = mColorLists.find("hair");
- if (it != mColorLists.end())
- colors = it->second;
- loadHair(paths.getStringValue("hairColorFile"),
- colors,
- SkipError_true);
- loadHair(paths.getStringValue("hairColorPatchFile"),
- colors,
- SkipError_true);
- StringVect list;
- VirtFs::getFilesInDir(paths.getStringValue(
- "hairColorPatchDir"), list, ".xml");
- FOR_EACH (StringVectCIter, it2, list)
- loadHair(*it2, colors, SkipError_true);
-
- mColorLists["hair"] = colors;
-
- loadColorLists(paths.getStringValue("itemColorsFile"),
- SkipError_false);
- loadColorLists(paths.getStringValue("itemColorsPatchFile"),
- SkipError_true);
- loadXmlDir("itemColorsPatchDir", loadColorLists);
-
- it = mColorLists.find("hair");
- if (it != mColorLists.end())
- mHairColorsSize = CAST_S32((*it).second.size());
- else
- mHairColorsSize = 0;
- mLoaded = true;
-}
-
-void ColorDB::loadHair(const std::string &fileName,
- std::map<ItemColor, ItemColorData> &colors,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "colors"))
- {
- logger->log("ColorDB: Failed to find hair colors file.");
- if (colors.find(ItemColor_zero) == colors.end())
- colors[ItemColor_zero] = ItemColorData(ItemColor_zero, "", "");
- delete doc;
- return;
- }
-
- reportAlways("Found legacy hair.xml");
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadHair(name, colors, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "color"))
- {
- const ItemColor id = fromInt(XML::getProperty(
- node, "id", 0), ItemColor);
-
- if (colors.find(id) != colors.end())
- {
- reportAlways("ColorDB: Redefinition of dye ID %d",
- toInt(id, int));
- }
-
- colors[id] = ItemColorData(id, XML::langProperty(node, "name", ""),
- XML::getProperty(node, "value", "#FFFFFF"));
- }
- }
-
- delete doc;
-}
-
-void ColorDB::loadColorLists(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadColorLists(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "list"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (name.empty())
- continue;
-
- std::map <ItemColor, ItemColorData> colors;
- const ColorListsIterator it = mColorLists.find(name);
-
- if (it != mColorLists.end())
- colors = it->second;
-
- for_each_xml_child_node(colorNode, node)
- {
- if (xmlNameEqual(colorNode, "color"))
- {
- const int id = XML::getProperty(colorNode, "id", -1);
- if (id > -1)
- {
- ItemColorData c(fromInt(id, ItemColor),
- XML::langProperty(colorNode, "name", ""),
- XML::getProperty(colorNode, "value", ""));
- colors[c.id] = c;
- }
- }
- }
- mColorLists[name] = colors;
- }
- }
- delete doc;
-}
-
-void ColorDB::unload()
-{
- logger->log1("Unloading color database...");
-
- mColorLists.clear();
- mLoaded = false;
-}
-
-std::string &ColorDB::getHairColorName(const ItemColor id)
-{
- if (!mLoaded)
- load();
-
- const ColorListsIterator it = mColorLists.find("hair");
- if (it == mColorLists.end())
- {
- reportAlways("ColorDB: Error, hair colors list empty");
- return mFail;
- }
-
- const ColorIterator i = (*it).second.find(id);
-
- if (i == (*it).second.end())
- {
- reportAlways("ColorDB: Error, unknown dye ID# %d",
- toInt(id, int));
- return mFail;
- }
- return i->second.name;
-}
-
-int ColorDB::getHairSize()
-{
- return mHairColorsSize;
-}
-
-const std::map <ItemColor, ItemColorData>
- *ColorDB::getColorsList(const std::string &name)
-{
- const ColorListsIterator it = mColorLists.find(name);
-
- if (it != mColorLists.end())
- return &it->second;
- return nullptr;
-}
diff --git a/src/resources/db/colordb.h b/src/resources/db/colordb.h
deleted file mode 100644
index 5189d7c85..000000000
--- a/src/resources/db/colordb.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_COLORDB_H
-#define RESOURCES_DB_COLORDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "resources/itemcolordata.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-/**
- * Color information database.
- */
-namespace ColorDB
-{
- /**
- * Loads the color data from <code>colors.xml</code>.
- */
- void load();
-
- /**
- * Loads the color data from <code>colors.xml</code>.
- */
- void loadHair(const std::string &fileName,
- std::map<ItemColor, ItemColorData> &colors,
- const SkipError skipError);
-
- void loadColorLists(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the color data
- */
- void unload();
-
- std::string &getHairColorName(const ItemColor id) A_WARN_UNUSED;
-
- int getHairSize() A_WARN_UNUSED;
-
- const std::map <ItemColor, ItemColorData> *getColorsList(const std::string
- &name)
- A_WARN_UNUSED;
-
- // Color DB
- typedef std::map<ItemColor, ItemColorData> Colors;
- typedef Colors::iterator ColorIterator;
- typedef std::map <std::string, std::map <ItemColor, ItemColorData> >
- ColorLists;
- typedef ColorLists::iterator ColorListsIterator;
-} // namespace ColorDB
-
-#endif // RESOURCES_DB_COLORDB_H
diff --git a/src/resources/db/commandsdb.cpp b/src/resources/db/commandsdb.cpp
deleted file mode 100644
index 4fc5136c4..000000000
--- a/src/resources/db/commandsdb.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/commandsdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-#include "textcommand.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- CommandsMap mCommands;
- bool mLoaded = false;
-} // namespace
-
-void CommandsDB::load()
-{
- if (mLoaded)
- unload();
- logger->log1("Initializing commands database...");
- loadXmlFile(paths.getStringValue("defaultCommandsFile"),
- SkipError_false);
- loadXmlFile(paths.getStringValue("defaultCommandsPatchFile"),
- SkipError_true);
- loadXmlDir("defaultCommandsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-static CommandTargetT parseTarget(const std::string &text)
-{
- if (text == "allow target")
- return CommandTarget::AllowTarget;
- else if (text == "need target")
- return CommandTarget::NeedTarget;
- else
- return CommandTarget::NoTarget;
-}
-
-void CommandsDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "commands"))
- {
- logger->log("Commands Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(commandNode, rootNode)
- {
- if (xmlNameEqual(commandNode, "include"))
- {
- const std::string name = XML::getProperty(commandNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (!xmlNameEqual(commandNode, "command"))
- continue;
-
- const int id = XML::getProperty(commandNode, "id", -1);
- if (id == -1)
- continue;
-
- const CommandsMapIter it = mCommands.find(id);
- if (it != mCommands.end())
- {
- logger->log("Commands database: duplicate id: %d", id);
- TextCommand *tempCmd = (*it).second;
- mCommands.erase(it);
- delete tempCmd;
- }
- const std::string name = XML::langProperty(
- commandNode, "name", "?");
- const std::string command = XML::getProperty(
- commandNode, "command", "");
- const std::string comment = XML::getProperty(
- commandNode, "comment", "");
- const CommandTargetT targetType = parseTarget(XML::getProperty(
- commandNode, "target", ""));
- const std::string icon = XML::getProperty(
- commandNode, "icon", "");
-#ifdef TMWA_SUPPORT
- const int skill1 = XML::getIntProperty(
- commandNode, "skill1", 0, 0, 1000000);
- const int level1 = XML::getIntProperty(
- commandNode, "level1", 0, 0, 1000);
- const int skill2 = XML::getIntProperty(
- commandNode, "skill2", 0, 0, 1000000);
- const int level2 = XML::getIntProperty(
- commandNode, "level2", 0, 0, 1000);
- const int mana = XML::getIntProperty(
- commandNode, "mana", 0, 0, 100000);
-#endif // TMWA_SUPPORT
-
- TextCommand *cmd = nullptr;
-#ifdef TMWA_SUPPORT
- if (skill1 != 0)
- {
- cmd = new TextCommand(id,
- name,
- command,
- comment,
- targetType,
- icon,
- level1,
- static_cast<MagicSchoolT>(skill2),
- level2,
- mana);
- }
- else
-#endif // TMWA_SUPPORT
- {
- cmd = new TextCommand(id,
- name,
- command,
- comment,
- targetType,
- icon);
- }
- mCommands[id] = cmd;
- }
-}
-
-void CommandsDB::unload()
-{
- logger->log1("Unloading commands database...");
- mCommands.clear();
- mLoaded = false;
-}
-
-std::map<int, TextCommand*> &CommandsDB::getAll()
-{
- return mCommands;
-}
diff --git a/src/resources/db/commandsdb.h b/src/resources/db/commandsdb.h
deleted file mode 100644
index 8c50a4367..000000000
--- a/src/resources/db/commandsdb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_COMMANDSDB_H
-#define RESOURCES_DB_COMMANDSDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-class TextCommand;
-
-typedef std::map<int, TextCommand*> CommandsMap;
-typedef CommandsMap::iterator CommandsMapIter;
-
-namespace CommandsDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- CommandsMap &getAll();
-} // namespace CommandsDB
-
-#endif // RESOURCES_DB_COMMANDSDB_H
diff --git a/src/resources/db/deaddb.cpp b/src/resources/db/deaddb.cpp
deleted file mode 100644
index 632c3a79f..000000000
--- a/src/resources/db/deaddb.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/deaddb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/translation/podict.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- STD_VECTOR<std::string> mMessages;
-} // namespace
-
-void DeadDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing dead database...");
-
- loadXmlFile(paths.getStringValue("deadMessagesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("deadMessagesPatchFile"), SkipError_true);
- loadXmlDir("deadMessagesPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void DeadDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "messages"))
- {
- logger->log("DeadDB: Failed to parse %s.",
- paths.getStringValue("deadMessagesFile").c_str());
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "message"))
- {
- XmlChar *const data = reinterpret_cast<XmlChar*>(
- XmlNodeGetContent(node));
- if (data == nullptr)
- continue;
- if (*data == 0)
- {
- XmlFree(data);
- continue;
- }
- mMessages.push_back(data);
- XmlFree(data);
- }
- }
-
- delete doc;
-}
-
-void DeadDB::unload()
-{
- logger->log1("Unloading dead database...");
- mMessages.clear();
- mLoaded = false;
-}
-
-std::string DeadDB::getRandomString()
-{
- const size_t sz = mMessages.size();
- if (sz == 0u)
- return std::string();
- return translator->getStr(mMessages[rand() % sz]);
-}
diff --git a/src/resources/db/deaddb.h b/src/resources/db/deaddb.h
deleted file mode 100644
index 4d2c3eab3..000000000
--- a/src/resources/db/deaddb.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_DEADDB_H
-#define RESOURCES_DB_DEADDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-/**
- * Char information database.
- */
-namespace DeadDB
-{
- /**
- * Loads the chars data.
- */
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the chars data
- */
- void unload();
-
- std::string getRandomString();
-} // namespace DeadDB
-
-#endif // RESOURCES_DB_DEADDB_H
diff --git a/src/resources/db/elementaldb.cpp b/src/resources/db/elementaldb.cpp
deleted file mode 100644
index 1bebf7633..000000000
--- a/src/resources/db/elementaldb.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/elementaldb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mElementalInfos;
- bool mLoaded = false;
-} // namespace
-
-void ElementalDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing elemental database...");
- loadXmlFile(paths.getStringValue("elementalsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("elementalsPatchFile"), SkipError_true);
- loadXmlDir("elementalsPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void ElementalDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "elementals"))
- {
- logger->log("Elemental Database: Error while loading %s!",
- paths.getStringValue("elementalsFile").c_str());
- mLoaded = true;
- return;
- }
-
- const int offset = XML::getProperty(rootNode, "offset", 0);
-
- // iterate <elemental>s
- for_each_xml_child_node(elementalNode, rootNode)
- {
- if (xmlNameEqual(elementalNode, "include"))
- {
- const std::string name = XML::getProperty(
- elementalNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (!xmlNameEqual(elementalNode, "elemental"))
- continue;
-
- const int id = XML::getProperty(elementalNode, "id", 0);
- BeingInfo *currentInfo = nullptr;
- if (mElementalInfos.find(fromInt(id + offset, BeingTypeId))
- != mElementalInfos.end())
- {
- logger->log("ElementalDb: Redefinition of elemental ID %d", id);
- currentInfo = mElementalInfos[fromInt(id + offset, BeingTypeId)];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setBlockType(BlockType::NONE);
- BeingCommon::readBasicAttributes(currentInfo,
- elementalNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo,
- elementalNode,
- 0);
-
- currentInfo->setMaxHP(XML::getProperty(elementalNode, "maxHP", 0));
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(
- elementalNode, "deadSortOffsetY", 31));
-
- currentInfo->setColorsList(XML::getProperty(elementalNode,
- "colors", ""));
-
- if (currentInfo->getMaxHP() != 0)
- currentInfo->setStaticMaxHP(true);
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, elementalNode)
- {
- BeingCommon::readObjectNodes(spriteNode, display,
- currentInfo, "ElementalDb");
- }
- currentInfo->setDisplay(display);
-
- mElementalInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
- }
-}
-
-void ElementalDb::unload()
-{
- logger->log1("Unloading elemental database...");
- delete_all(mElementalInfos);
- mElementalInfos.clear();
-
- mLoaded = false;
-}
-
-
-BeingInfo *ElementalDb::get(const BeingTypeId id)
-{
- BeingInfoIterator i = mElementalInfos.find(id);
-
- if (i == mElementalInfos.end())
- {
- i = mElementalInfos.find(id);
- if (i == mElementalInfos.end())
- {
- reportAlways("ElementalDb: Warning, unknown elemental ID "
- "%d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- }
- return i->second;
-}
diff --git a/src/resources/db/elementaldb.h b/src/resources/db/elementaldb.h
deleted file mode 100644
index 50a67c183..000000000
--- a/src/resources/db/elementaldb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_ELEMENTALDB_H
-#define RESOURCES_DB_ELEMENTALDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingInfo;
-
-/**
- * Elemental information database.
- */
-namespace ElementalDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace ElementalDb
-
-#endif // RESOURCES_DB_ELEMENTALDB_H
diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp
deleted file mode 100644
index e519b531d..000000000
--- a/src/resources/db/emotedb.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/emotedb.h"
-
-#include "client.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-#include "resources/emoteinfo.h"
-#include "resources/emotesprite.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "debug.h"
-
-namespace
-{
- EmoteInfos mEmoteInfos;
- EmoteToEmote mEmotesAlt;
- EmoteInfo mUnknown;
- bool mLoaded = false;
- int mLastEmote = 0;
-} // namespace
-
-void EmoteDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing emote database...");
-
- EmoteSprite *const unknownSprite = new EmoteSprite;
- unknownSprite->sprite = AnimatedSprite::load(pathJoin(paths.getStringValue(
- "sprites"), paths.getStringValue(
- "spriteErrorFile")));
- unknownSprite->name = "unknown";
- unknownSprite->id = 0;
- mUnknown.sprites.push_back(unknownSprite);
-
- mLastEmote = 0;
- loadXmlFile(paths.getStringValue("emotesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("emotesPatchFile"), SkipError_true);
- loadXmlDir("emotesPatchDir", loadXmlFile);
- loadSpecialXmlFile("graphics/sprites/manaplus_emotes.xml",
- SkipError_false);
-
- mLoaded = true;
-}
-
-void EmoteDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodePtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "emotes"))
- {
- logger->log("Emote Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- // iterate <emote>s
- for_each_xml_child_node(emoteNode, rootNode)
- {
- if (xmlNameEqual(emoteNode, "include"))
- {
- const std::string name = XML::getProperty(emoteNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(emoteNode, "emote"))
- {
- continue;
- }
-
- const int id = XML::getProperty(emoteNode, "id", -1);
- // skip hight images
- if (id > 19 || (Client::isTmw() && id > 13))
- continue;
-
- if (id == -1)
- {
- reportAlways("Emote Database: Emote with missing ID in %s!",
- paths.getStringValue("emotesFile").c_str());
- continue;
- }
- EmoteInfo *currentInfo = nullptr;
- if (mEmoteInfos.find(id) != mEmoteInfos.end())
- currentInfo = mEmoteInfos[id];
- else
- currentInfo = new EmoteInfo;
- if (currentInfo == nullptr)
- continue;
- currentInfo->time = XML::getProperty(emoteNode, "time", 500);
- currentInfo->effectId = XML::getProperty(emoteNode, "effect", -1);
-
- for_each_xml_child_node(spriteNode, emoteNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- EmoteSprite *const currentSprite = new EmoteSprite;
- currentSprite->sprite = AnimatedSprite::load(pathJoin(
- paths.getStringValue("sprites"),
- XmlChildContent(spriteNode)),
- XML::getProperty(spriteNode, "variant", 0));
- currentSprite->name = XML::langProperty(
- spriteNode, "name", "");
- currentSprite->id = id;
- currentInfo->sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- currentInfo->particles.push_back(XmlChildContent(spriteNode));
- }
- }
- mEmoteInfos[id] = currentInfo;
- if (id > mLastEmote)
- mLastEmote = id;
- }
-}
-
-void EmoteDB::loadSpecialXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodePtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "emotes"))
- {
- logger->log1("Emote Database: Error while loading"
- " manaplus_emotes.xml!");
- return;
- }
-
- // iterate <emote>s
- for_each_xml_child_node(emoteNode, rootNode)
- {
- if (xmlNameEqual(emoteNode, "include"))
- {
- const std::string name = XML::getProperty(emoteNode, "name", "");
- if (!name.empty())
- loadSpecialXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(emoteNode, "emote"))
- {
- continue;
- }
-
- const int id = XML::getProperty(emoteNode, "id", -1);
- if (id == -1)
- {
- reportAlways("Emote Database: Emote with missing ID in "
- "manaplus_emotes.xml!");
- continue;
- }
- const int altId = XML::getProperty(emoteNode, "altid", -1);
-
- EmoteInfo *currentInfo = nullptr;
- if (mEmoteInfos.find(id) != mEmoteInfos.end())
- currentInfo = mEmoteInfos[id];
- if (currentInfo == nullptr)
- currentInfo = new EmoteInfo;
- currentInfo->time = XML::getProperty(emoteNode, "time", 500);
- currentInfo->effectId = XML::getProperty(emoteNode, "effect", -1);
-
- for_each_xml_child_node(spriteNode, emoteNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- EmoteSprite *const currentSprite = new EmoteSprite;
- currentSprite->sprite = AnimatedSprite::load(pathJoin(
- paths.getStringValue("sprites"),
- XmlChildContent(spriteNode)),
- XML::getProperty(spriteNode, "variant", 0));
- currentSprite->name = XML::langProperty(
- spriteNode, "name", "");
- currentSprite->id = id;
- currentInfo->sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- currentInfo->particles.push_back(XmlChildContent(spriteNode));
- }
- }
- mEmoteInfos[id] = currentInfo;
- if (altId != -1)
- mEmotesAlt[altId] = id;
-
- if (id > mLastEmote)
- mLastEmote = id;
- }
-}
-
-void EmoteDB::unload()
-{
- logger->log1("Unloading emote database...");
- FOR_EACH (EmoteInfos::const_iterator, i, mEmoteInfos)
- {
- if (i->second != nullptr)
- {
- std::list<EmoteSprite*> &sprites = i->second->sprites;
- while (!sprites.empty())
- {
- delete sprites.front()->sprite;
- delete sprites.front();
- sprites.pop_front();
- }
- delete i->second;
- }
- }
-
- mEmoteInfos.clear();
-
- std::list<EmoteSprite*> &sprites = mUnknown.sprites;
- while (!sprites.empty())
- {
- delete sprites.front()->sprite;
- delete sprites.front();
- sprites.pop_front();
- }
-
- mLoaded = false;
-}
-
-const EmoteInfo *EmoteDB::get(const int id, const bool allowNull)
-{
- const EmoteInfos::const_iterator i = mEmoteInfos.find(id);
-
- if (i == mEmoteInfos.end())
- {
- if (allowNull)
- return nullptr;
- reportAlways("EmoteDB: Warning, unknown emote ID %d requested",
- id);
- return &mUnknown;
- }
- return i->second;
-}
-
-const EmoteInfo *EmoteDB::get2(int id, const bool allowNull)
-{
- const EmoteToEmote::const_iterator it = mEmotesAlt.find(id);
- if (it != mEmotesAlt.end())
- id = (*it).second;
-
- const EmoteInfos::const_iterator i = mEmoteInfos.find(id);
-
- if (i == mEmoteInfos.end())
- {
- if (allowNull)
- return nullptr;
- reportAlways("EmoteDB: Warning, unknown emote ID %d requested",
- id);
- return &mUnknown;
- }
- return i->second;
-}
-
-const EmoteSprite *EmoteDB::getSprite(const int id, const bool allowNull)
-{
- const EmoteInfo *const info = get(id, allowNull);
- if (info == nullptr)
- return nullptr;
-
- return info->sprites.front();
-}
-
-const int &EmoteDB::getLast()
-{
- return mLastEmote;
-}
-
-int EmoteDB::size()
-{
- return static_cast<signed int>(mEmoteInfos.size());
-}
-
-int EmoteDB::getIdByIndex(const int index)
-{
- if (index < 0 || index >= static_cast<signed int>(mEmoteInfos.size()))
- return 0;
- EmoteInfos::const_iterator it = mEmoteInfos.begin();
- for (int f = 0; f < index; f ++)
- ++ it;
- return (*it).first;
-}
diff --git a/src/resources/db/emotedb.h b/src/resources/db/emotedb.h
deleted file mode 100644
index 6d5420b51..000000000
--- a/src/resources/db/emotedb.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_EMOTEDB_H
-#define RESOURCES_DB_EMOTEDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct EmoteInfo;
-struct EmoteSprite;
-
-typedef std::map<int, EmoteInfo*> EmoteInfos;
-typedef std::map<int, int> EmoteToEmote;
-
-/**
- * Emote information database.
- */
-namespace EmoteDB
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void loadSpecialXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- const EmoteInfo *get(const int id,
- const bool allowNull = false) A_WARN_UNUSED;
-
- const EmoteInfo *get2(int id, const bool allowNull = false) A_WARN_UNUSED;
-
- const EmoteSprite *getSprite(const int id, const bool allowNull = false)
- A_WARN_UNUSED;
-
- const int &getLast() A_CONST A_WARN_UNUSED;
-
- int getIdByIndex(const int index);
-
- int size();
-
- typedef EmoteInfos::iterator EmoteInfosIterator;
-} // namespace EmoteDB
-
-#endif // RESOURCES_DB_EMOTEDB_H
diff --git a/src/resources/db/groupdb.cpp b/src/resources/db/groupdb.cpp
deleted file mode 100644
index e4c909c9a..000000000
--- a/src/resources/db/groupdb.cpp
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/groupdb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-#include "resources/groupinfo.h"
-
-#include "debug.h"
-
-namespace
-{
- GroupDb::GroupInfos mGroups;
- const GroupInfo mEmptyGroup;
- bool mLoaded = false;
-} // namespace
-
-void GroupDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing group database...");
-
- loadXmlFile(paths.getStringValue("groupsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("groupsPatchFile"), SkipError_true);
- loadXmlDir("groupsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-#define servercommandFirst(name) \
- if (str == #name) \
- return ServerCommandType::name; \
- else
-#define servercommand(name) \
- if (str == #name) \
- return ServerCommandType::name; \
- else
-#define servercommand2(name1, name2) \
- if (str == #name2) \
- return ServerCommandType::name1; \
- else
-
-static ServerCommandTypeT parseCommand(const std::string &str,
- const int id)
-{
-#include "resources/servercommands.inc"
- {
- reportAlways("GroupsDb: unknown command name: '%s' in group id '%d'.",
- str.c_str(),
- id);
- }
-
- return ServerCommandType::Max;
-}
-
-SERVERCOMMANDS_VOID
-#undef servercommandFirst
-#undef servercommand
-#undef servercommand2
-
-#define serverpermissionFirst(name) \
- if (str == #name) \
- return ServerPermissionType::name; \
- else
-#define serverpermission(name) \
- if (str == #name) \
- return ServerPermissionType::name; \
- else
-
-static ServerPermissionTypeT parsePermission(const std::string &str,
- const int id)
-{
-#include "resources/serverpermissions.inc"
- {
- reportAlways("GroupsDb: unknown permission name: "
- "'%s' in group id '%d'.",
- str.c_str(),
- id);
- }
-
- return ServerPermissionType::Max;
-}
-
-SERVERPERMISSION_VOID
-#undef serverpermissionFirst
-#undef serverpermission
-
-static ServerCommandEnable::Type parseUseFlag(const std::string &str,
- const int id)
-{
- if (str == "self")
- {
- return ServerCommandEnable::Self;
- }
- else if (str == "other")
- {
- return ServerCommandEnable::Other;
- }
- else if (str == "both")
- {
- return ServerCommandEnable::Both;
- }
- else if (str == "false")
- {
- return ServerCommandEnable::No;
- }
- else
- {
- reportAlways("GroupsDb: unknown use flag: '%s' in group id '%d'."
- "Possible values 'self', 'other', 'both'.",
- str.c_str(),
- id);
- return ServerCommandEnable::No;
- }
-}
-
-static void loadCommands(XmlNodePtr rootNode,
- const int id,
- GroupInfo *groupInfo) A_NONNULL(3);
-static void loadCommands(XmlNodePtr rootNode,
- const int id,
- GroupInfo *groupInfo)
-{
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "command"))
- {
- const std::string nameStr = XML::getProperty(node,
- "name",
- "");
- const std::string useStr = XML::getProperty(node,
- "use",
- "");
- ServerCommandTypeT name = parseCommand(nameStr, id);
- if (name == ServerCommandType::Max)
- continue;
- ServerCommandEnable::Type useFlag = parseUseFlag(useStr, id);
- if (useFlag == ServerCommandEnable::No)
- continue;
- groupInfo->mCommands[CAST_SIZE(name)] = useFlag;
- }
- }
-}
-
-static void loadPermissions(XmlNodePtr rootNode,
- const int id,
- GroupInfo *groupInfo) A_NONNULL(3);
-static void loadPermissions(XmlNodePtr rootNode,
- const int id,
- GroupInfo *groupInfo)
-{
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "permission"))
- {
- const std::string nameStr = XML::getProperty(node,
- "name",
- "");
- ServerPermissionTypeT perm = parsePermission(nameStr, id);
- if (perm == ServerPermissionType::Max)
- continue;
- if (!XML::getBoolProperty(node,
- "enable",
- true))
- {
- continue;
- }
- groupInfo->mPermissions[CAST_SIZE(perm)] = Enable_true;
- }
- }
-}
-
-static void loadSubNodes(XmlNodePtr groupNode,
- const int id,
- GroupInfo *groupInfo) A_NONNULL(3);
-static void loadSubNodes(XmlNodePtr groupNode,
- const int id,
- GroupInfo *groupInfo)
-{
- for_each_xml_child_node(node, groupNode)
- {
- if (xmlNameEqual(node, "commands"))
- loadCommands(node, id, groupInfo);
- if (xmlNameEqual(node, "permissions"))
- loadPermissions(node, id, groupInfo);
- }
-}
-
-static void parseInherit(XmlNodePtr groupNode,
- const int id,
- GroupInfo *groupInfo) A_NONNULL(3);
-static void parseInherit(XmlNodePtr groupNode,
- const int id,
- GroupInfo *groupInfo)
-{
- const std::string inherit = XML::langProperty(groupNode,
- "inherit",
- "");
- STD_VECTOR<int> parts;
- splitToIntVector(parts, inherit, ',');
- FOR_EACH (STD_VECTOR<int>::const_iterator, it, parts)
- {
- const int id2 = *it;
- GroupDb::GroupInfos::const_iterator it2 = mGroups.find(id2);
- if (it2 == mGroups.end())
- {
- reportAlways("Unknown inherit group id '%d' in group '%d'",
- id2,
- id);
- continue;
- }
- GroupInfo *const groupInfo2 = (*it2).second;
- for (size_t f = 0; f < CAST_SIZE(ServerCommandType::Max); f ++)
- {
- ServerCommandEnable::Type enable = groupInfo2->mCommands[f];
- if (enable != ServerCommandEnable::No)
- groupInfo->mCommands[f] = enable;
- }
- for (size_t f = 0; f < CAST_SIZE(ServerPermissionType::Max); f ++)
- {
- if (groupInfo2->mPermissions[f] == Enable_true)
- groupInfo->mPermissions[f] = Enable_true;
- }
- }
-}
-
-void GroupDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if (rootNode == nullptr ||
- !xmlNameEqual(rootNode, "groups"))
- {
- if (skipError == SkipError_true)
- {
- logger->log("GroupsDb: Error while loading %s!",
- fileName.c_str());
- }
- else
- {
- reportAlways("GroupsDb: Error while loading %s!",
- fileName.c_str());
- }
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (xmlNameEqual(node, "group"))
- {
- const int id = XML::getProperty(node,
- "id",
- -1);
- if (id < 0)
- {
- reportAlways("Empty id field in GroupDb");
- continue;
- }
- GroupInfosIter it = mGroups.find(id);
- GroupInfo *group = nullptr;
- if (it != mGroups.end())
- {
- reportAlways("GroupDb: group with id %d already added",
- id);
- group = (*it).second;
- }
- else
- {
- group = new GroupInfo;
- mGroups[id] = group;
- }
- group->name = XML::langProperty(node,
- "name",
- "");
- group->longName = XML::langProperty(node,
- "longName",
- "");
- group->badge = XML::langProperty(node,
- "badge",
- paths.getStringValue("gmbadge"));
- group->showBadge = XML::getBoolProperty(node,
- "showBadge",
- false);
- loadSubNodes(node, id, group);
- parseInherit(node, id, group);
- }
- }
-}
-
-void GroupDb::unload()
-{
- logger->log1("Unloading group database...");
- FOR_EACH (GroupInfosIter, it, mGroups)
- {
- delete (*it).second;
- }
- mGroups.clear();
- mLoaded = false;
-}
-
-const std::string &GroupDb::getName(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return mEmptyGroup.name;
- }
- return (*it).second->name;
-}
-
-const std::string &GroupDb::getLongName(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return mEmptyGroup.longName;
- }
- return (*it).second->longName;
-}
-
-bool GroupDb::getShowBadge(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return mEmptyGroup.showBadge;
- }
- return (*it).second->showBadge;
-}
-
-const std::string &GroupDb::getBadge(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return mEmptyGroup.badge;
- }
- return (*it).second->badge;
-}
-
-const GroupInfo *GroupDb::getGroup(const int id)
-{
- GroupInfos::const_iterator it = mGroups.find(id);
- if (it == mGroups.end())
- {
- reportAlways("Unknown group id requested: %d", id);
- return &mEmptyGroup;
- }
- return (*it).second;
-}
-
-#ifdef UNITTESTS
-GroupDb::GroupInfos &GroupDb::getGroups()
-{
- return mGroups;
-}
-#endif // UNITTESTS
diff --git a/src/resources/db/groupdb.h b/src/resources/db/groupdb.h
deleted file mode 100644
index 020649001..000000000
--- a/src/resources/db/groupdb.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_GROUPDB_H
-#define RESOURCES_DB_GROUPDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct GroupInfo;
-
-namespace GroupDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
- const std::string &getName(const int id) A_WARN_UNUSED;
- const std::string &getLongName(const int id) A_WARN_UNUSED;
- bool getShowBadge(const int id) A_WARN_UNUSED;
- const std::string &getBadge(const int id) A_WARN_UNUSED;
- const GroupInfo *getGroup(const int id) A_WARN_UNUSED RETURNS_NONNULL;
-
- typedef std::map<int, GroupInfo*> GroupInfos;
- typedef GroupInfos::iterator GroupInfosIter;
-
-#ifdef UNITTESTS
- GroupDb::GroupInfos &getGroups();
-#endif // UNITTESTS
-} // namespace GroupDb
-
-#endif // RESOURCES_DB_GROUPDB_H
diff --git a/src/resources/db/homunculusdb.cpp b/src/resources/db/homunculusdb.cpp
deleted file mode 100644
index 83912e936..000000000
--- a/src/resources/db/homunculusdb.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/homunculusdb.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "configuration.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mHomunculusInfos;
- bool mLoaded = false;
-} // namespace
-
-void HomunculusDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing homunculus database...");
- loadXmlFile(paths.getStringValue("homunculusesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("homunculusesPatchFile"), SkipError_true);
- loadXmlDir("homunculusesPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void HomunculusDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "homunculuses"))
- {
- logger->log("Homunculus Database: Error while loading %s!",
- paths.getStringValue("homunculusesFile").c_str());
- mLoaded = true;
- return;
- }
-
- const int offset = XML::getProperty(rootNode, "offset", 0);
-
- // iterate <homunculus>s
- for_each_xml_child_node(homunculusNode, rootNode)
- {
- if (xmlNameEqual(homunculusNode, "include"))
- {
- const std::string name = XML::getProperty(
- homunculusNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (!xmlNameEqual(homunculusNode, "homunculus"))
- continue;
-
- const int id = XML::getProperty(homunculusNode, "id", 0);
- BeingInfo *currentInfo = nullptr;
- if (mHomunculusInfos.find(fromInt(id + offset, BeingTypeId))
- != mHomunculusInfos.end())
- {
- logger->log("HomunculusDB: Redefinition of homunculus ID %d", id);
- currentInfo = mHomunculusInfos[fromInt(id + offset, BeingTypeId)];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setBlockType(BlockType::NONE);
- currentInfo->setName(XML::langProperty(
- // TRANSLATORS: unknown info name
- homunculusNode, "name", _("unnamed")));
-
- BeingCommon::readBasicAttributes(currentInfo,
- homunculusNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo,
- homunculusNode,
- 0);
- BeingCommon::readAiAttributes(currentInfo,
- homunculusNode);
-
- currentInfo->setMaxHP(XML::getProperty(homunculusNode, "maxHP", 0));
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(
- homunculusNode, "deadSortOffsetY", 31));
-
- currentInfo->setColorsList(XML::getProperty(homunculusNode,
- "colors", ""));
-
- if (currentInfo->getMaxHP() != 0)
- currentInfo->setStaticMaxHP(true);
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, homunculusNode)
- {
- BeingCommon::readObjectNodes(spriteNode, display,
- currentInfo, "HomunculusDB");
- }
- currentInfo->setDisplay(display);
-
- mHomunculusInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
- }
-}
-
-void HomunculusDB::unload()
-{
- logger->log1("Unloading homunculus database...");
- delete_all(mHomunculusInfos);
- mHomunculusInfos.clear();
-
- mLoaded = false;
-}
-
-BeingInfo *HomunculusDB::get(const BeingTypeId id)
-{
- BeingInfoIterator i = mHomunculusInfos.find(id);
-
- if (i == mHomunculusInfos.end())
- {
- i = mHomunculusInfos.find(id);
- if (i == mHomunculusInfos.end())
- {
- reportAlways("HomunculusDB: Warning, unknown homunculus ID "
- "%d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- }
- return i->second;
-}
diff --git a/src/resources/db/homunculusdb.h b/src/resources/db/homunculusdb.h
deleted file mode 100644
index 5a064567a..000000000
--- a/src/resources/db/homunculusdb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_HOMUNCULUSDB_H
-#define RESOURCES_DB_HOMUNCULUSDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingInfo;
-
-/**
- * Homunculus information database.
- */
-namespace HomunculusDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace HomunculusDB
-
-#endif // RESOURCES_DB_HOMUNCULUSDB_H
diff --git a/src/resources/db/horsedb.cpp b/src/resources/db/horsedb.cpp
deleted file mode 100644
index 00228ecd7..000000000
--- a/src/resources/db/horsedb.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/horsedb.h"
-
-#include "configuration.h"
-
-#include "enums/resources/spritedirection.h"
-
-#include "resources/beingcommon.h"
-#include "resources/horseinfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-namespace
-{
- HorseInfos mHorseInfos;
- HorseInfo mUnknown;
- bool mLoaded = false;
-} // namespace
-
-#define loadSprite(name) \
- { \
- SpriteReference *const currentSprite = new SpriteReference; \
- currentSprite->sprite = pathJoin(paths.getStringValue("sprites"), \
- XmlChildContent(spriteNode)); \
- currentSprite->variant = XML::getProperty( \
- spriteNode, "variant", 0); \
- currentInfo->name.push_back(currentSprite); \
- }
-
-static void loadDownSprites(XmlNodePtrConst parentNode,
- HorseInfo *const currentInfo);
-
-static void loadUpSprites(XmlNodePtrConst parentNode,
- HorseInfo *const currentInfo);
-
-void HorseDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing horse database...");
-
- SpriteReference *currentSprite = new SpriteReference;
- currentSprite->sprite = pathJoin(paths.getStringValue("sprites"),
- paths.getStringValue("spriteErrorFile"));
- currentSprite->variant = 0;
- mUnknown.downSprites.push_back(currentSprite);
-
- currentSprite = new SpriteReference;
- currentSprite->sprite = pathJoin(paths.getStringValue("sprites"),
- paths.getStringValue("spriteErrorFile"));
- currentSprite->variant = 0;
- mUnknown.upSprites.push_back(currentSprite);
-
- loadXmlFile(paths.getStringValue("horsesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("horsesPatchFile"), SkipError_true);
- loadXmlDir("horsesPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-static int parseDirectionName(const std::string &name)
-{
- int id = -1;
- if (name == "down")
- {
- id = SpriteDirection::DOWN;
- }
- else if (name == "downleft" || name == "leftdown")
- {
- id = SpriteDirection::DOWNLEFT;
- }
- else if (name == "left")
- {
- id = SpriteDirection::LEFT;
- }
- else if (name == "upleft" || name == "leftup")
- {
- id = SpriteDirection::UPLEFT;
- }
- else if (name == "up")
- {
- id = SpriteDirection::UP;
- }
- else if (name == "upright" || name == "rightup")
- {
- id = SpriteDirection::UPRIGHT;
- }
- else if (name == "right")
- {
- id = SpriteDirection::RIGHT;
- }
- else if (name == "downright" || name == "rightdown")
- {
- id = SpriteDirection::DOWNRIGHT;
- }
- // hack for died action.
- else if (name == "died")
- {
- id = 9;
- }
-
- return id;
-}
-
-static void loadRiderOffset(XmlNodePtrConst node,
- HorseInfo *const currentInfo)
-{
- const std::string dirName = XML::getProperty(node,
- "direction", "");
- const int dir = parseDirectionName(dirName);
- if (dir == -1)
- {
- reportAlways("Wrong or missing horse rider direcion: %s",
- dirName.c_str());
- return;
- }
- HorseOffset &offset = currentInfo->offsets[dir];
- offset.riderOffsetX = XML::getProperty(node,
- "riderOffsetX", 0);
- offset.riderOffsetY = XML::getProperty(node,
- "riderOffsetY", 0);
-}
-
-void HorseDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodePtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "horses"))
- {
- logger->log("Horse Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- // iterate <emote>s
- for_each_xml_child_node(horseNode, rootNode)
- {
- if (xmlNameEqual(horseNode, "include"))
- {
- const std::string name = XML::getProperty(horseNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(horseNode, "horse"))
- {
- continue;
- }
-
- const int id = XML::getProperty(horseNode, "id", -1);
-
- if (id == -1)
- {
- reportAlways("Horse Database: Horse with missing ID in %s!",
- paths.getStringValue("horsesFile").c_str());
- continue;
- }
- HorseInfo *currentInfo = nullptr;
- if (mHorseInfos.find(id) != mHorseInfos.end())
- currentInfo = mHorseInfos[id];
- else
- currentInfo = new HorseInfo;
-
- if (currentInfo == nullptr)
- continue;
- for_each_xml_child_node(spriteNode, horseNode)
- {
- if (xmlNameEqual(spriteNode, "down"))
- loadDownSprites(spriteNode, currentInfo);
- else if (xmlNameEqual(spriteNode, "up"))
- loadUpSprites(spriteNode, currentInfo);
- else if (xmlNameEqual(spriteNode, "offset"))
- loadRiderOffset(spriteNode, currentInfo);
- }
- mHorseInfos[id] = currentInfo;
- }
-}
-
-static void loadOffset(XmlNodePtrConst node,
- HorseInfo *const currentInfo,
- const bool isUp)
-{
- const std::string dirName = XML::getProperty(node,
- "direction", "");
- const int dir = parseDirectionName(dirName);
- if (dir == -1)
- {
- reportAlways("Wrong or missing horse direcion: %s",
- dirName.c_str());
- return;
- }
- HorseOffset &offset = currentInfo->offsets[dir];
- if (isUp)
- {
- offset.upOffsetX = XML::getProperty(node,
- "horseOffsetX", 0);
- offset.upOffsetY = XML::getProperty(node,
- "horseOffsetY", 0);
- }
- else
- {
- offset.downOffsetX = XML::getProperty(node,
- "horseOffsetX", 0);
- offset.downOffsetY = XML::getProperty(node,
- "horseOffsetY", 0);
- }
-}
-
-static void loadDownSprites(XmlNodePtrConst parentNode,
- HorseInfo *const currentInfo)
-{
- for_each_xml_child_node(spriteNode, parentNode)
- {
- if (xmlNameEqual(spriteNode, "offset"))
- loadOffset(spriteNode, currentInfo, false);
- if (!XmlHaveChildContent(spriteNode))
- continue;
- if (xmlNameEqual(spriteNode, "sprite"))
- loadSprite(downSprites)
- }
-}
-
-static void loadUpSprites(XmlNodePtrConst parentNode,
- HorseInfo *const currentInfo)
-{
- for_each_xml_child_node(spriteNode, parentNode)
- {
- if (xmlNameEqual(spriteNode, "offset"))
- loadOffset(spriteNode, currentInfo, true);
- if (!XmlHaveChildContent(spriteNode))
- continue;
- if (xmlNameEqual(spriteNode, "sprite"))
- loadSprite(upSprites)
- }
-}
-
-void HorseDB::unload()
-{
- logger->log1("Unloading horse database...");
- FOR_EACH (HorseInfos::const_iterator, i, mHorseInfos)
- {
- delete_all(i->second->upSprites);
- delete_all(i->second->downSprites);
- delete i->second;
- }
- mHorseInfos.clear();
-
- delete_all(mUnknown.upSprites);
- delete_all(mUnknown.downSprites);
- mUnknown.upSprites.clear();
- mUnknown.downSprites.clear();
-
- mLoaded = false;
-}
-
-HorseInfo *HorseDB::get(const int id, const bool allowNull)
-{
- const HorseInfos::const_iterator i = mHorseInfos.find(id);
-
- if (i == mHorseInfos.end())
- {
- if (allowNull)
- return nullptr;
- reportAlways("HorseDB: Warning, unknown horse ID %d requested",
- id);
- return &mUnknown;
- }
- return i->second;
-}
-
-int HorseDB::size()
-{
- return static_cast<signed int>(mHorseInfos.size());
-}
diff --git a/src/resources/db/horsedb.h b/src/resources/db/horsedb.h
deleted file mode 100644
index 226e53213..000000000
--- a/src/resources/db/horsedb.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_HORSEDB_H
-#define RESOURCES_DB_HORSEDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct HorseInfo;
-
-typedef std::map<int, HorseInfo*> HorseInfos;
-
-/**
- * Horse information database.
- */
-namespace HorseDB
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void loadSpecialXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- HorseInfo *get(const int id,
- const bool allowNull = false) A_WARN_UNUSED;
-
- int size();
-
- typedef HorseInfos::iterator HorseInfosIterator;
-} // namespace HorseDB
-
-#endif // RESOURCES_DB_HORSEDB_H
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
deleted file mode 100644
index 274b44bb2..000000000
--- a/src/resources/db/itemdb.cpp
+++ /dev/null
@@ -1,1232 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/itemdb.h"
-
-#include "const/resources/map/map.h"
-
-#include "configuration.h"
-
-#include "enums/resources/spritedirection.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "resources/iteminfo.h"
-#include "resources/itemmenuitem.h"
-#include "resources/itemtypemapdata.h"
-
-#include "resources/db/itemfielddb.h"
-
-#include "resources/item/itemfieldtype.h"
-
-#include "resources/sprite/spritereference.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-#endif // TMWA_SUPPORT
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/stdmove.h"
-#include "utils/stringmap.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- ItemDB::ItemInfos mItemInfos;
- ItemDB::NamedItemInfos mNamedItemInfos;
- ItemInfo *mUnknown = nullptr;
- bool mLoaded = false;
- bool mConstructed = false;
- StringVect mTagNames;
- StringIntMap mTags;
- std::map<std::string, ItemSoundEvent::Type> mSoundNames;
- int mNumberOfHairstyles = 1;
-} // namespace
-
-// Forward declarations
-static void loadSpriteRef(ItemInfo *const itemInfo,
- XmlNodeConstPtr node) A_NONNULL(1);
-static void loadSoundRef(ItemInfo *const itemInfo,
- XmlNodeConstPtr node) A_NONNULL(1);
-static void loadFloorSprite(SpriteDisplay &display,
- XmlNodeConstPtrConst node);
-static void loadReplaceSprite(ItemInfo *const itemInfo,
- XmlNodeConstPtr replaceNode) A_NONNULL(1);
-static void loadOrderSprite(ItemInfo *const itemInfo,
- XmlNodeConstPtr node,
- const bool drawAfter) A_NONNULL(1);
-static int parseSpriteName(const std::string &name);
-static int parseDirectionName(const std::string &name);
-
-static ItemDbTypeT itemTypeFromString(const std::string &name)
-{
- const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
- for (size_t f = 0; f < sz; f ++)
- {
- const ItemTypeMap &type = itemTypeMap[f];
- if (type.name == name)
- return type.type;
- }
- logger->log("Unknown item type: " + name);
- return ItemDbType::UNUSABLE;
-}
-
-static std::string useButtonFromItemType(const ItemDbTypeT &type)
-{
- const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
- for (size_t f = 0; f < sz; f ++)
- {
- const ItemTypeMap &item = itemTypeMap[f];
- if (item.type == type)
- {
- if (item.useButton.empty())
- return std::string();
- return gettext(item.useButton.c_str());
- }
- }
- logger->log("Unknown item type");
- return std::string();
-}
-
-static std::string useButton2FromItemType(const ItemDbTypeT &type)
-{
- const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
- for (size_t f = 0; f < sz; f ++)
- {
- const ItemTypeMap &item = itemTypeMap[f];
- if (item.type == type)
- {
- if (item.useButton2.empty())
- return std::string();
- return gettext(item.useButton2.c_str());
- }
- }
- logger->log("Unknown item type");
- return std::string();
-}
-
-static void readFields(std::string &effect,
- XmlNodeConstPtr node,
- const ItemFieldDb::FieldInfos &fields)
-{
- if (translator == nullptr)
- return;
-
- FOR_EACH (ItemFieldDb::FieldInfos::const_iterator, it, fields)
- {
- const std::string fieldName = (*it).first;
- const ItemFieldType *const field = (*it).second;
-
- std::string value = XML::getProperty(node,
- fieldName.c_str(),
- "");
- if (value.empty())
- continue;
- if (!effect.empty())
- effect.append(" / ");
- if (field->sign && isDigit(value))
- value = std::string("+").append(value);
- const std::string format = translator->getStr(field->description);
- effect.append(strprintf(format.c_str(),
- value.c_str()));
- }
-}
-
-static void initStatic()
-{
- mConstructed = true;
- mSoundNames["hit"] = ItemSoundEvent::HIT;
- mSoundNames["strike"] = ItemSoundEvent::MISS;
- mSoundNames["miss"] = ItemSoundEvent::MISS;
- mSoundNames["use"] = ItemSoundEvent::USE;
- mSoundNames["equip"] = ItemSoundEvent::EQUIP;
- mSoundNames["unequip"] = ItemSoundEvent::UNEQUIP;
- mSoundNames["drop"] = ItemSoundEvent::DROP;
- mSoundNames["pickup"] = ItemSoundEvent::PICKUP;
- mSoundNames["take"] = ItemSoundEvent::TAKE;
- mSoundNames["put"] = ItemSoundEvent::PUT;
- mSoundNames["usecard"] = ItemSoundEvent::USECARD;
-}
-
-void ItemDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing item database...");
-
- if (!mConstructed)
- initStatic();
-
- int tagNum = 0;
-
- mTags.clear();
- mTagNames.clear();
- mTagNames.push_back("All");
- mTagNames.push_back("Usable");
- mTagNames.push_back("Unusable");
- mTagNames.push_back("Equipment");
- mTags["All"] = tagNum ++;
- mTags["Usable"] = tagNum ++;
- mTags["Unusable"] = tagNum ++;
- mTags["Equipment"] = tagNum ++;
-
- mUnknown = new ItemInfo;
- // TRANSLATORS: item name
- mUnknown->setName(_("Unknown item"));
- mUnknown->setDisplay(SpriteDisplay());
- std::string errFile = paths.getStringValue("spriteErrorFile");
- mUnknown->setSprite(errFile, Gender::MALE, 0);
- mUnknown->setSprite(errFile, Gender::FEMALE, 0);
- mUnknown->setSprite(errFile, Gender::OTHER, 0);
- mUnknown->addTag(mTags["All"]);
- loadXmlFile(paths.getStringValue("itemsFile"),
- tagNum,
- SkipError_false);
- loadXmlFile(paths.getStringValue("itemsPatchFile"),
- tagNum,
- SkipError_true);
-
- StringVect list;
- VirtFs::getFilesInDir(paths.getStringValue("itemsPatchDir"),
- list,
- ".xml");
- FOR_EACH (StringVectCIter, it, list)
- loadXmlFile(*it, tagNum, SkipError_true);
-
- // Hairstyles are encoded as negative numbers. Count how far negative
- // we can go.
- int hairstyles = 1;
- while (ItemDB::exists(-hairstyles) &&
- ItemDB::get(-hairstyles).getSprite(Gender::MALE,
- BeingTypeId_zero) != paths.getStringValue("spriteErrorFile"))
- {
- hairstyles ++;
- }
- mNumberOfHairstyles = hairstyles;
-
- int races = 100;
- while (ItemDB::exists(-races) &&
- ItemDB::get(-races).getSprite(Gender::MALE, BeingTypeId_zero) !=
- paths.getStringValue("spriteErrorFile"))
- {
- races ++;
- }
-}
-
-static void loadMenu(XmlNodePtrConst parentNode,
- STD_VECTOR<ItemMenuItem> &menu)
-{
- for_each_xml_child_node(node, parentNode)
- {
- if (xmlNameEqual(node, "menu"))
- {
- const std::string name1 = XML::langProperty(node,
- "name1", "");
- const std::string name2 = XML::langProperty(node,
- "name2", "");
- const std::string command1 = XML::getProperty(node,
- "command1", "");
- const std::string command2 = XML::getProperty(node,
- "command2", command1);
- menu.push_back(ItemMenuItem(name1,
- name2,
- command1,
- command2));
- }
- }
-}
-
-static bool getIsEquipment(const ItemDbTypeT type)
-{
- switch (type)
- {
- case ItemDbType::EQUIPMENT_ONE_HAND_WEAPON:
- case ItemDbType::EQUIPMENT_TWO_HANDS_WEAPON:
- case ItemDbType::EQUIPMENT_TORSO:
- case ItemDbType::EQUIPMENT_ARMS:
- case ItemDbType::EQUIPMENT_HEAD:
- case ItemDbType::EQUIPMENT_LEGS:
- case ItemDbType::EQUIPMENT_SHIELD:
- case ItemDbType::EQUIPMENT_RING:
- case ItemDbType::EQUIPMENT_NECKLACE:
- case ItemDbType::EQUIPMENT_FEET:
- case ItemDbType::EQUIPMENT_AMMO:
- case ItemDbType::EQUIPMENT_CHARM:
- return true;
- case ItemDbType::UNUSABLE:
- case ItemDbType::USABLE:
- case ItemDbType::CARD:
- case ItemDbType::SPRITE_RACE:
- case ItemDbType::SPRITE_HAIR:
- default:
- return false;
- }
-}
-
-void ItemDB::loadXmlFile(const std::string &fileName,
- int &tagNum,
- const SkipError skipError)
-{
- if (fileName.empty())
- {
- mLoaded = true;
- return;
- }
-
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "items"))
- {
- logger->log("ItemDB: Error while loading %s!", fileName.c_str());
- mLoaded = true;
- return;
- }
-
- const ItemFieldDb::FieldInfos &requiredFields =
- ItemFieldDb::getRequiredFields();
- const ItemFieldDb::FieldInfos &addFields =
- ItemFieldDb::getAddFields();
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, tagNum, skipError);
- continue;
- }
- if (!xmlNameEqual(node, "item"))
- continue;
-
- const int id = XML::getProperty(node, "id", 0);
- ItemInfo *itemInfo = nullptr;
-
- if (id == 0)
- {
- reportAlways("ItemDB: Invalid or missing item ID in %s!",
- fileName.c_str());
- continue;
- }
- else if (mItemInfos.find(id) != mItemInfos.end())
- {
- logger->log("ItemDB: Redefinition of item ID %d", id);
- itemInfo = mItemInfos[id];
- }
- if (itemInfo == nullptr)
- itemInfo = new ItemInfo;
-
- const std::string typeStr = XML::getProperty(node, "type", "");
- int weight = XML::getProperty(node, "weight", 0);
- int view = XML::getProperty(node, "view", 0);
- const int cardColor = XML::getProperty(node, "cardColor", -1);
- const int inherit = XML::getProperty(node, "inherit", -1);
-
- std::string name = XML::langProperty(node, "name", "");
- std::string nameEn = XML::getProperty(node, "name", "");
- std::string image = XML::getProperty(node, "image", "");
- std::string floor = XML::getProperty(node, "floor", "");
- std::string description = XML::langProperty(node, "description", "");
- std::string attackAction = XML::getProperty(node, "attack-action", "");
- std::string skyAttackAction = XML::getProperty(
- node, "skyattack-action", "");
- std::string waterAttackAction = XML::getProperty(
- node, "waterattack-action", "");
- std::string rideAttackAction = XML::getProperty(
- node, "rideattack-action", "");
- std::string drawBefore = XML::getProperty(node, "drawBefore", "");
- std::string drawAfter = XML::getProperty(node, "drawAfter", "");
- const int maxFloorOffset = XML::getIntProperty(
- node, "maxFloorOffset", mapTileSize, 0, mapTileSize);
- const int maxFloorOffsetX = XML::getIntProperty(
- node, "maxFloorOffsetX", maxFloorOffset, 0, mapTileSize);
- const int maxFloorOffsetY = XML::getIntProperty(
- node, "maxFloorOffsetY", maxFloorOffset, 0, mapTileSize);
- std::string useButton = XML::langProperty(node, "useButton", "");
- std::string useButton2 = XML::langProperty(node, "useButton2", "");
- std::string colors = XML::getProperty(node, "colors", "");
- std::string iconColors = XML::getProperty(node, "iconColors", "");
- if (iconColors.empty())
- iconColors = colors;
-
- // check for empty hair palete
- if (id <= -1 && id > -100)
- {
- if (colors.empty())
- colors = "hair";
- if (iconColors.empty())
- iconColors = "hair";
- }
-
- std::string tags[3];
- tags[0] = XML::getProperty(node, "tag",
- XML::getProperty(node, "tag1", ""));
- tags[1] = XML::getProperty(node, "tag2", "");
- tags[2] = XML::getProperty(node, "tag3", "");
-
- const int drawPriority = XML::getProperty(node, "drawPriority", 0);
-
- int attackRange = XML::getProperty(node, "attack-range", 0);
- std::string missileParticle = XML::getProperty(
- node, "missile-particle", "");
- float missileZ = XML::getFloatProperty(
- node, "missile-z", 32.0f);
- int missileLifeTime = XML::getProperty(
- node, "missile-lifetime", 500);
- float missileSpeed = XML::getFloatProperty(
- node, "missile-speed", 7.0f);
- float missileDieDistance = XML::getFloatProperty(
- node, "missile-diedistance", 8.0f);
- int hitEffectId = XML::getProperty(node, "hit-effect-id",
- paths.getIntValue("hitEffectId"));
- int criticalEffectId = XML::getProperty(
- node, "critical-hit-effect-id",
- paths.getIntValue("criticalHitEffectId"));
- int missEffectId = XML::getProperty(node, "miss-effect-id",
- paths.getIntValue("missEffectId"));
-
- SpriteDisplay display;
- display.image = image;
- if (!floor.empty())
- display.floor = STD_MOVE(floor);
- else
- display.floor = image;
-
- const ItemInfo *inheritItemInfo = nullptr;
-
- if (inherit >= 0)
- {
- if (mItemInfos.find(inherit) != mItemInfos.end())
- {
- inheritItemInfo = mItemInfos[inherit];
- }
- else
- {
- reportAlways("Inherit item %d from not existing item %d",
- id,
- inherit);
- }
- }
-
- itemInfo->setId(id);
- if (name.empty() && (inheritItemInfo != nullptr))
- name = inheritItemInfo->getName();
- // TRANSLATORS: item info name
- itemInfo->setName(name.empty() ? _("unnamed") : name);
- if (nameEn.empty())
- {
- // TRANSLATORS: item info name
- itemInfo->setNameEn(name.empty() ? _("unnamed") : name);
- }
- else
- {
- itemInfo->setNameEn(nameEn);
- }
-
- if (description.empty() && (inheritItemInfo != nullptr))
- description = inheritItemInfo->getDescription();
- itemInfo->setDescription(description);
- if (typeStr.empty())
- {
- if (inheritItemInfo != nullptr)
- itemInfo->setType(inheritItemInfo->getType());
- else
- itemInfo->setType(itemTypeFromString("other"));
- }
- else
- {
- itemInfo->setType(itemTypeFromString(typeStr));
- }
- itemInfo->setType(itemTypeFromString(typeStr));
- if (useButton.empty() && (inheritItemInfo != nullptr))
- useButton = inheritItemInfo->getUseButton();
- if (useButton.empty())
- useButton = useButtonFromItemType(itemInfo->getType());
- itemInfo->setUseButton(useButton);
- if (useButton2.empty() && (inheritItemInfo != nullptr))
- useButton2 = inheritItemInfo->getUseButton();
- if (useButton2.empty())
- useButton2 = useButton2FromItemType(itemInfo->getType());
- itemInfo->setUseButton2(useButton2);
- itemInfo->addTag(mTags["All"]);
- itemInfo->setProtected(XML::getBoolProperty(
- node, "sellProtected", false));
- if (cardColor != -1)
- itemInfo->setCardColor(fromInt(cardColor, ItemColor));
- else if (inheritItemInfo != nullptr)
- itemInfo->setCardColor(inheritItemInfo->getCardColor());
-
- switch (itemInfo->getType())
- {
- case ItemDbType::USABLE:
- itemInfo->addTag(mTags["Usable"]);
- break;
- case ItemDbType::CARD:
- case ItemDbType::UNUSABLE:
- itemInfo->addTag(mTags["Unusable"]);
- break;
- default:
- case ItemDbType::EQUIPMENT_ONE_HAND_WEAPON:
- case ItemDbType::EQUIPMENT_TWO_HANDS_WEAPON:
- case ItemDbType::EQUIPMENT_TORSO:
- case ItemDbType::EQUIPMENT_ARMS:
- case ItemDbType::EQUIPMENT_HEAD:
- case ItemDbType::EQUIPMENT_LEGS:
- case ItemDbType::EQUIPMENT_SHIELD:
- case ItemDbType::EQUIPMENT_RING:
- case ItemDbType::EQUIPMENT_NECKLACE:
- case ItemDbType::EQUIPMENT_FEET:
- case ItemDbType::EQUIPMENT_AMMO:
- case ItemDbType::EQUIPMENT_CHARM:
- case ItemDbType::SPRITE_RACE:
- case ItemDbType::SPRITE_HAIR:
- itemInfo->addTag(mTags["Equipment"]);
- break;
- }
- for (int f = 0; f < 3; f++)
- {
- if (!tags[f].empty())
- {
- if (mTags.find(tags[f]) == mTags.end())
- {
- mTagNames.push_back(tags[f]);
- mTags[tags[f]] = tagNum ++;
- }
- itemInfo->addTag(mTags[tags[f]]);
- }
- }
-
- std::string effect;
- readFields(effect, node, requiredFields);
- readFields(effect, node, addFields);
- std::string temp = XML::langProperty(node, "effect", "");
- if (!effect.empty() && !temp.empty())
- effect.append(" / ");
- effect.append(temp);
-
- if (inheritItemInfo != nullptr)
- {
- if (view == 0)
- view = inheritItemInfo->getView();
- if (weight == 0)
- weight = inheritItemInfo->getWeight();
- if (attackAction.empty())
- attackAction = inheritItemInfo->getAttackAction();
- if (skyAttackAction.empty())
- skyAttackAction = inheritItemInfo->getSkyAttackAction();
- if (waterAttackAction.empty())
- waterAttackAction = inheritItemInfo->getWaterAttackAction();
- if (rideAttackAction.empty())
- rideAttackAction = inheritItemInfo->getRideAttackAction();
- if (attackRange == 0)
- attackRange = inheritItemInfo->getAttackRange();
- if (hitEffectId == 0)
- hitEffectId = inheritItemInfo->getHitEffectId();
- if (criticalEffectId == 0)
- criticalEffectId = inheritItemInfo->getCriticalHitEffectId();
- if (missEffectId == 0)
- missEffectId = inheritItemInfo->getMissEffectId();
- if (colors.empty())
- colors = inheritItemInfo->getColorsListName();
- if (iconColors.empty())
- iconColors = inheritItemInfo->getIconColorsListName();
- if (effect.empty())
- effect = inheritItemInfo->getEffect();
-
- const MissileInfo &inheritMissile =
- inheritItemInfo->getMissileConst();
- if (missileParticle.empty())
- missileParticle = inheritMissile.particle;
- if (missileZ == 32.0F)
- missileZ = inheritMissile.z;
- if (missileLifeTime == 500)
- missileLifeTime = inheritMissile.lifeTime;
- if (missileSpeed == 7.0F)
- missileSpeed = inheritMissile.speed;
- if (missileDieDistance == 8.0F)
- missileDieDistance = inheritMissile.dieDistance;
- }
-
- itemInfo->setView(view);
- itemInfo->setWeight(weight);
- itemInfo->setAttackAction(attackAction);
- itemInfo->setSkyAttackAction(skyAttackAction);
- itemInfo->setWaterAttackAction(waterAttackAction);
- itemInfo->setRideAttackAction(rideAttackAction);
- itemInfo->setAttackRange(attackRange);
- itemInfo->setHitEffectId(hitEffectId);
- itemInfo->setCriticalHitEffectId(criticalEffectId);
- itemInfo->setMissEffectId(missEffectId);
- itemInfo->setDrawBefore(-1, parseSpriteName(drawBefore));
- itemInfo->setDrawAfter(-1, parseSpriteName(drawAfter));
- itemInfo->setDrawPriority(-1, drawPriority);
- itemInfo->setColorsList(colors);
- itemInfo->setIconColorsList(iconColors);
- itemInfo->setMaxFloorOffsetX(maxFloorOffsetX);
- itemInfo->setMaxFloorOffsetY(maxFloorOffsetY);
- itemInfo->setPickupCursor(XML::getProperty(
- node, "pickupCursor", "pickup"));
- itemInfo->setEffect(effect);
-
- MissileInfo &missile = itemInfo->getMissile();
- missile.particle = STD_MOVE(missileParticle);
- missile.z = missileZ;
- missile.lifeTime = missileLifeTime;
- missile.speed = missileSpeed;
- missile.dieDistance = missileDieDistance;
-
- for_each_xml_child_node(itemChild, node)
- {
- if (xmlNameEqual(itemChild, "sprite"))
- {
- loadSpriteRef(itemInfo, itemChild);
- }
- else if (xmlNameEqual(itemChild, "particlefx"))
- {
- if (XmlHaveChildContent(itemChild))
- display.particles.push_back(XmlChildContent(itemChild));
- }
- else if (xmlNameEqual(itemChild, "sound"))
- {
- loadSoundRef(itemInfo, itemChild);
- }
- else if (xmlNameEqual(itemChild, "floor"))
- {
- loadFloorSprite(display, itemChild);
- }
- else if (xmlNameEqual(itemChild, "replace"))
- {
- loadReplaceSprite(itemInfo, itemChild);
- }
- else if (xmlNameEqual(itemChild, "drawAfter"))
- {
- loadOrderSprite(itemInfo, itemChild, true);
- }
- else if (xmlNameEqual(itemChild, "drawBefore"))
- {
- loadOrderSprite(itemInfo, itemChild, false);
- }
- else if (xmlNameEqual(itemChild, "inventory"))
- {
- loadMenu(itemChild, itemInfo->getInventoryMenu());
- }
- else if (xmlNameEqual(itemChild, "storage"))
- {
- loadMenu(itemChild, itemInfo->getStorageMenu());
- }
- else if (xmlNameEqual(itemChild, "cart"))
- {
- loadMenu(itemChild, itemInfo->getCartMenu());
- }
- }
-
-/*
- logger->log("start dump item: %d", id);
- if (itemInfo->isRemoveSprites())
- {
- for (int f = 0; f < 10; f ++)
- {
- logger->log("dir: %d", f);
- SpriteToItemMap *const spriteToItems
- = itemInfo->getSpriteToItemReplaceMap(f);
- if (!spriteToItems)
- {
- logger->log("null");
- continue;
- }
- for (SpriteToItemMapCIter itr = spriteToItems->begin(),
- itr_end = spriteToItems->end(); itr != itr_end; ++ itr)
- {
- const int remSprite = itr->first;
- const IntMap &itemReplacer = itr->second;
- logger->log("sprite: %d", remSprite);
-
- for (IntMapCIter repIt = itemReplacer.begin(),
- repIt_end = itemReplacer.end();
- repIt != repIt_end; ++ repIt)
- {
- logger->log("from %d to %d", repIt->first,
- repIt->second);
- }
- }
- }
- }
-
- logger->log("--------------------------------");
- logger->log("end dump item");
-*/
-
- itemInfo->setDisplay(display);
-
- mItemInfos[id] = itemInfo;
- if (!name.empty())
- {
- temp = normalize(name);
- mNamedItemInfos[temp] = itemInfo;
- }
- if (!nameEn.empty())
- {
- temp = normalize(nameEn);
- mNamedItemInfos[temp] = itemInfo;
- }
-
- if (!attackAction.empty())
- {
- if (attackRange == 0)
- {
- reportAlways("ItemDB: Missing attack range from weapon %i!",
- id);
- }
- }
-
- STD_VECTOR<ItemMenuItem> &inventoryMenu = itemInfo->getInventoryMenu();
-
- if (inventoryMenu.empty())
- {
- std::string name1 = itemInfo->getUseButton();
- std::string name2 = itemInfo->getUseButton2();
- const bool isEquipment = getIsEquipment(itemInfo->getType());
-
- if (isEquipment)
- {
- if (name1.empty())
- {
- // TRANSLATORS: popup menu item
- name1 = _("Equip");
- }
- if (name2.empty())
- {
- // TRANSLATORS: popup menu item
- name2 = _("Unequip");
- }
- }
- else
- {
- if (name1.empty())
- {
- // TRANSLATORS: popup menu item
- name1 = _("Use");
- }
- if (name2.empty())
- {
- // TRANSLATORS: popup menu item
- name2 = _("Use");
- }
- }
- inventoryMenu.push_back(ItemMenuItem(
- name1,
- name2,
- "useinv 'INVINDEX'",
- "useinv 'INVINDEX'"));
- }
-
-#define CHECK_PARAM(param) \
- if (param.empty()) \
- { \
- logger->log("ItemDB: Missing " #param " attribute for item %i!", \
- id); \
- }
-
- if (id >= 0 && typeStr != "other")
- {
- CHECK_PARAM(name)
- CHECK_PARAM(description)
- CHECK_PARAM(image)
- }
-#undef CHECK_PARAM
- }
-
- mLoaded = true;
-}
-
-const StringVect &ItemDB::getTags()
-{
- return mTagNames;
-}
-
-int ItemDB::getTagId(const std::string &tagName)
-{
- return mTags[tagName];
-}
-
-void ItemDB::unload()
-{
- logger->log1("Unloading item database...");
-
- delete2(mUnknown);
-
- delete_all(mItemInfos);
- mItemInfos.clear();
- mNamedItemInfos.clear();
- mTags.clear();
- mTagNames.clear();
- mLoaded = false;
-}
-
-bool ItemDB::exists(const int id)
-{
- if (!mLoaded)
- return false;
-
- const ItemInfos::const_iterator i = mItemInfos.find(id);
- return i != mItemInfos.end();
-}
-
-bool ItemDB::exists(const std::string &name)
-{
- if (!mLoaded)
- return false;
-
- const NamedItemInfos::const_iterator i = mNamedItemInfos.find(
- normalize(name));
- return i != mNamedItemInfos.end();
-}
-
-const ItemInfo &ItemDB::get(const int id)
-{
- if (!mLoaded)
- load();
-
- const ItemInfos::const_iterator i = mItemInfos.find(id);
-
- if (i == mItemInfos.end())
- {
- reportAlways("ItemDB: Warning, unknown item ID# %d", id);
- return *mUnknown;
- }
-
- return *(i->second);
-}
-
-const ItemInfo &ItemDB::get(const std::string &name)
-{
- if (!mLoaded)
- load();
-
- const NamedItemInfos::const_iterator i = mNamedItemInfos.find(
- normalize(name));
-
- if (i == mNamedItemInfos.end())
- {
- if (!name.empty())
- {
- reportAlways("ItemDB: Warning, unknown item name \"%s\"",
- name.c_str());
- }
- return *mUnknown;
- }
-
- return *(i->second);
-}
-
-const ItemDB::ItemInfos &ItemDB::getItemInfos()
-{
- return mItemInfos;
-}
-
-const ItemInfo &ItemDB::getEmpty()
-{
- return *mUnknown;
-}
-
-static int parseSpriteName(const std::string &name)
-{
- int id = -1;
- if (name == "race" || name == "type")
- {
- id = 0;
- }
- else if (name == "shoes" || name == "boot" || name == "boots")
- {
- id = 1;
- }
- else if (name == "bottomclothes" || name == "bottom" || name == "pants")
- {
- id = 2;
- }
- else if (name == "topclothes" || name == "top"
- || name == "torso" || name == "body")
- {
- id = 3;
- }
- else if (name == "misc1")
- {
- id = 4;
- }
- else if (name == "misc2" || name == "scarf" || name == "scarfs")
- {
- id = 5;
- }
- else if (name == "hair")
- {
- id = 6;
- }
- else if (name == "hat" || name == "hats")
- {
- id = 7;
- }
- else if (name == "wings")
- {
- id = 8;
- }
- else if (name == "glove" || name == "gloves")
- {
- id = 9;
- }
- else if (name == "weapon" || name == "weapons")
- {
- id = 10;
- }
- else if (name == "shield" || name == "shields")
- {
- id = 11;
- }
- else if (name == "amulet" || name == "amulets")
- {
- id = 12;
- }
- else if (name == "ring" || name == "rings")
- {
- id = 13;
- }
-
- return id;
-}
-
-static int parseDirectionName(const std::string &name)
-{
- int id = -1;
- if (name == "down")
- {
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- id = -2;
- else
-#endif
- id = SpriteDirection::DOWN;
- }
- else if (name == "downleft" || name == "leftdown")
- {
- id = SpriteDirection::DOWNLEFT;
- }
- else if (name == "left")
- {
- id = SpriteDirection::LEFT;
- }
- else if (name == "upleft" || name == "leftup")
- {
- id = SpriteDirection::UPLEFT;
- }
- else if (name == "up")
- {
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- id = -3;
- else
-#endif
- id = SpriteDirection::UP;
- }
- else if (name == "upright" || name == "rightup")
- {
- id = SpriteDirection::UPRIGHT;
- }
- else if (name == "right")
- {
- id = SpriteDirection::RIGHT;
- }
- else if (name == "downright" || name == "rightdown")
- {
- id = SpriteDirection::DOWNRIGHT;
- }
- else if (name == "downall")
- {
- id = -2;
- }
- else if (name == "upall")
- {
- id = -3;
- }
- // hack for died action.
- else if (name == "died")
- {
- id = 9;
- }
-
- return id;
-}
-
-static void loadSpriteRef(ItemInfo *const itemInfo, XmlNodeConstPtr node)
-{
- const std::string gender = XML::getProperty(node, "gender", "unisex");
- if ((node == nullptr) || !XmlHaveChildContent(node))
- return;
-
- const std::string filename = XmlChildContent(node);
-
- const int race = XML::getProperty(node, "race", 0);
- if (gender == "male" || gender == "unisex")
- itemInfo->setSprite(filename, Gender::MALE, race);
- if (gender == "female" || gender == "unisex")
- itemInfo->setSprite(filename, Gender::FEMALE, race);
- if (gender == "other" || gender == "unisex")
- itemInfo->setSprite(filename, Gender::OTHER, race);
-}
-
-static void loadSoundRef(ItemInfo *const itemInfo, XmlNodeConstPtr node)
-{
- if (node == nullptr ||
- !XmlHaveChildContent(node))
- {
- return;
- }
- const std::string event = XML::getProperty(node, "event", "");
- const int delay = XML::getProperty(node, "delay", 0);
-
- const std::map<std::string, ItemSoundEvent::Type>::const_iterator
- it = mSoundNames.find(event);
- if (it != mSoundNames.end())
- {
- const std::string filename = XmlChildContent(node);
- itemInfo->addSound((*it).second, filename, delay);
- }
- else
- {
- reportAlways("ItemDB: Ignoring unknown sound event '%s'",
- event.c_str());
- }
-}
-
-static void loadFloorSprite(SpriteDisplay &display,
- XmlNodeConstPtrConst floorNode)
-{
- if (floorNode == nullptr)
- return;
- for_each_xml_child_node(spriteNode, floorNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant
- = XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- display.particles.push_back(XmlChildContent(spriteNode));
- }
- }
-}
-
-static void loadReplaceSprite(ItemInfo *const itemInfo,
- XmlNodeConstPtr replaceNode)
-{
- if (replaceNode == nullptr)
- return;
- const std::string removeSprite = XML::getProperty(
- replaceNode, "sprite", "");
- const int direction = parseDirectionName(XML::getProperty(
- replaceNode, "direction", "all"));
-
- itemInfo->setRemoveSprites();
-
- switch (direction)
- {
- case -1:
- {
- if (removeSprite.empty())
- { // remove all sprites
- for (int f = 0; f < 10; f ++)
- {
- for (int sprite = 0; sprite < 13; sprite ++)
- itemInfo->addReplaceSprite(sprite, f);
- }
- }
- else
- { // replace only given sprites
- for (int f = 0; f < 10; f ++)
- {
- IntMap *const mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), f);
- if (mapList == nullptr)
- continue;
- for_each_xml_child_node(itemNode, replaceNode)
- {
- if (xmlNameEqual(itemNode, "item"))
- {
- const int from = XML::getProperty(
- itemNode, "from", 0);
- const int to = XML::getProperty(
- itemNode, "to", 1);
- (*mapList)[from] = to;
- }
- }
- }
- }
- break;
- }
- case -2:
- {
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWN);
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWNLEFT);
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWNRIGHT);
-
- for_each_xml_child_node(itemNode, replaceNode)
- {
- if (xmlNameEqual(itemNode, "item"))
- {
- const int from = XML::getProperty(itemNode, "from", 0);
- const int to = XML::getProperty(itemNode, "to", 1);
- IntMap *mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), SpriteDirection::DOWN);
- if (mapList != nullptr)
- (*mapList)[from] = to;
-
- mapList = itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWNLEFT);
- if (mapList != nullptr)
- (*mapList)[from] = to;
-
- mapList = itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::DOWNRIGHT);
- if (mapList != nullptr)
- (*mapList)[from] = to;
- }
- }
- break;
- }
- case -3:
- {
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UP);
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UPLEFT);
- itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UPRIGHT);
-
- for_each_xml_child_node(itemNode, replaceNode)
- {
- if (xmlNameEqual(itemNode, "item"))
- {
- const int from = XML::getProperty(itemNode, "from", 0);
- const int to = XML::getProperty(itemNode, "to", 1);
- IntMap *mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), SpriteDirection::UP);
- if (mapList != nullptr)
- (*mapList)[from] = to;
-
- mapList = itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UPLEFT);
- if (mapList != nullptr)
- (*mapList)[from] = to;
-
- mapList = itemInfo->addReplaceSprite(parseSpriteName(
- removeSprite), SpriteDirection::UPRIGHT);
- if (mapList != nullptr)
- (*mapList)[from] = to;
- }
- }
- break;
- }
- default:
- {
- IntMap *const mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), direction);
- if (mapList == nullptr)
- return;
- for_each_xml_child_node(itemNode, replaceNode)
- {
- if (xmlNameEqual(itemNode, "item"))
- {
- const int from = XML::getProperty(itemNode, "from", 0);
- const int to = XML::getProperty(itemNode, "to", 1);
- (*mapList)[from] = to;
- }
- }
- break;
- }
- }
-}
-
-static void loadOrderSprite(ItemInfo *const itemInfo,
- XmlNodeConstPtr node,
- const bool drawAfter)
-{
- const int sprite = parseSpriteName(XML::getProperty(node, "name", ""));
- const int priority = XML::getProperty(node, "priority", 0);
-
- const int direction = parseDirectionName(XML::getProperty(
- node, "direction", "all"));
- if (drawAfter)
- itemInfo->setDrawAfter(direction, sprite);
- else
- itemInfo->setDrawBefore(direction, sprite);
- itemInfo->setDrawPriority(direction, priority);
-}
-
-std::string ItemDB::getNamesStr(const STD_VECTOR<int> &parts)
-{
- std::string str;
- FOR_EACH (STD_VECTOR<int>::const_iterator, it, parts)
- {
- const int id = *it;
- if (exists(id))
- {
- if (!str.empty())
- str.append(",");
- str.append(get(id).getName());
- }
- }
- return str;
-}
-
-int ItemDB::getNumOfHairstyles()
-{
- return mNumberOfHairstyles;
-}
-
-#ifdef UNITTESTS
-ItemDB::NamedItemInfos &ItemDB::getNamedItemInfosTest()
-{
- return mNamedItemInfos;
-}
-
-ItemDB::ItemInfos &ItemDB::getItemInfosTest()
-{
- return mItemInfos;
-}
-#endif // UNITTESTS
diff --git a/src/resources/db/itemdb.h b/src/resources/db/itemdb.h
deleted file mode 100644
index 1515d3ba0..000000000
--- a/src/resources/db/itemdb.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_ITEMDB_H
-#define RESOURCES_DB_ITEMDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/stringvector.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-class ItemInfo;
-
-/**
- * Item information database.
- */
-namespace ItemDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- int &tagNum,
- const SkipError skipError);
-
- const StringVect &getTags();
-
- bool exists(const int id) A_WARN_UNUSED;
- bool exists(const std::string &name) A_WARN_UNUSED;
-
- const ItemInfo &get(const int id) A_WARN_UNUSED;
- const ItemInfo &get(const std::string &name) A_WARN_UNUSED;
-
- const ItemInfo &getEmpty() A_WARN_UNUSED;
-
- int getNumOfHairstyles() A_WARN_UNUSED;
-
- // Items database
- typedef std::map<int, ItemInfo*> ItemInfos;
- typedef std::map<std::string, ItemInfo*> NamedItemInfos;
-
- const ItemDB::ItemInfos &getItemInfos();
-
- std::string getNamesStr(const STD_VECTOR<int> &parts);
-
-#ifdef UNITTESTS
- ItemDB::NamedItemInfos &getNamedItemInfosTest();
-
- ItemDB::ItemInfos &getItemInfosTest();
-#endif // UNITTESTS
-
- int getTagId(const std::string &tagName) A_WARN_UNUSED;
-} // namespace ItemDB
-
-#endif // RESOURCES_DB_ITEMDB_H
diff --git a/src/resources/db/itemfielddb.cpp b/src/resources/db/itemfielddb.cpp
deleted file mode 100644
index 8a32ccc02..000000000
--- a/src/resources/db/itemfielddb.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/itemfielddb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-
-#include "resources/beingcommon.h"
-
-#include "resources/item/itemfieldtype.h"
-
-#include "debug.h"
-
-namespace
-{
- ItemFieldDb::FieldInfos mRequiredInfos;
- ItemFieldDb::FieldInfos mAddInfos;
- bool mLoaded = false;
-} // namespace
-
-void ItemFieldDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing item field database...");
-
- loadXmlFile(paths.getStringValue("itemFieldsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("itemFieldsPatchFile"), SkipError_true);
- loadXmlDir("itemFieldsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-static void loadFields(XmlNodeConstPtr groupNode,
- ItemFieldDb::FieldInfos &fields1,
- ItemFieldDb::FieldInfos &fields2)
-{
- for_each_xml_child_node(node, groupNode)
- {
- if (!xmlNameEqual(node, "field"))
- continue;
-
- const std::string name = XML::getProperty(node,
- "name",
- "");
- if (name.empty())
- {
- reportAlways("Empty name field in ItemFieldDb");
- continue;
- }
- const std::string description = XML::langProperty(node,
- "description",
- "");
- if (description.empty())
- {
- reportAlways("Empty description field in ItemFieldDb");
- continue;
- }
- const bool sign = XML::getBoolProperty(node,
- "signed",
- true);
- if (fields2.find(name) != fields2.end())
- {
- reportAlways(
- "Same field name detected in requeted and add groups: %s",
- name.c_str());
- continue;
- }
- if (fields1.find(name) != fields1.end())
- {
- reportAlways(
- "Same field name detected: %s",
- name.c_str());
- continue;
- }
- fields1[name] = new ItemFieldType(name,
- description,
- sign);
- }
-}
-
-void ItemFieldDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "itemfields"))
- {
- logger->log("ItemFieldDb: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (xmlNameEqual(node, "required"))
- loadFields(node, mRequiredInfos, mAddInfos);
- else if (xmlNameEqual(node, "add"))
- loadFields(node, mAddInfos, mRequiredInfos);
- }
-}
-
-void ItemFieldDb::unload()
-{
- logger->log1("Unloading item database...");
-
- delete_all(mRequiredInfos);
- mRequiredInfos.clear();
- delete_all(mAddInfos);
- mAddInfos.clear();
- mLoaded = false;
-}
-
-const ItemFieldDb::FieldInfos &ItemFieldDb::getRequiredFields()
-{
- return mRequiredInfos;
-}
-
-const ItemFieldDb::FieldInfos &ItemFieldDb::getAddFields()
-{
- return mAddInfos;
-}
diff --git a/src/resources/db/itemfielddb.h b/src/resources/db/itemfielddb.h
deleted file mode 100644
index 9ccbce0fa..000000000
--- a/src/resources/db/itemfielddb.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_ITEMFIELDDB_H
-#define RESOURCES_DB_ITEMFIELDDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct ItemFieldType;
-
-namespace ItemFieldDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- typedef std::map<std::string, ItemFieldType*> FieldInfos;
-
- const FieldInfos &getRequiredFields();
-
- const FieldInfos &getAddFields();
-} // namespace ItemFieldDb
-
-#endif // RESOURCES_DB_ITEMFIELDDB_H
diff --git a/src/resources/db/itemoptiondb.cpp b/src/resources/db/itemoptiondb.cpp
deleted file mode 100644
index b138e7521..000000000
--- a/src/resources/db/itemoptiondb.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/itemoptiondb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "resources/db/itemfielddb.h"
-
-#include "debug.h"
-
-namespace
-{
- ItemOptionDb::OptionInfos mOptions;
- const STD_VECTOR<ItemFieldType*> mEmptyOption;
- bool mLoaded = false;
-} // namespace
-
-void ItemOptionDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing item options database...");
- loadXmlFile(paths.getStringValue("itemOptionsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("itemOptionsPatchFile"), SkipError_true);
- loadXmlDir("itemOptionsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-static void addFieldByName(STD_VECTOR<ItemFieldType*> &options,
- XmlNodeConstPtr node,
- const ItemFieldDb::FieldInfos &fields,
- const char *const name)
-{
- std::string value = XML::getProperty(node, name, "");
- if (value.empty())
- return;
-
- FOR_EACH (ItemFieldDb::FieldInfos::const_iterator, it, fields)
- {
- const std::string fieldName = (*it).first;
- if (fieldName == value)
- {
- options.push_back((*it).second);
- return;
- }
- }
-}
-
-static void readOptionFields(STD_VECTOR<ItemFieldType*> &options,
- XmlNodeConstPtr node,
- const ItemFieldDb::FieldInfos &fields)
-{
- addFieldByName(options, node, fields, "field");
- for (int f = 0; f < 15; f ++)
- {
- const std::string field = strprintf("field%d", f);
- addFieldByName(options, node, fields, field.c_str());
- }
-}
-
-void ItemOptionDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "itemoptions"))
- {
- if (skipError == SkipError_true)
- {
- logger->log("ItemFieldDb: Error while loading %s!",
- fileName.c_str());
- }
- else
- {
- reportAlways("ItemFieldDb: Error while loading %s!",
- fileName.c_str());
- }
- return;
- }
-
- const ItemFieldDb::FieldInfos &requiredFields =
- ItemFieldDb::getRequiredFields();
- const ItemFieldDb::FieldInfos &addFields =
- ItemFieldDb::getAddFields();
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (xmlNameEqual(node, "option"))
- {
- const int id = XML::getProperty(node,
- "id",
- 0);
- if (id <= 0)
- {
- reportAlways("Empty id field in ItemOptionDb");
- continue;
- }
- STD_VECTOR<ItemFieldType*> &options = mOptions[id];
- readOptionFields(options, node, requiredFields);
- readOptionFields(options, node, addFields);
- }
- }
-}
-
-void ItemOptionDb::unload()
-{
- logger->log1("Unloading item options database...");
- mOptions.clear();
- mLoaded = false;
-}
-
-const STD_VECTOR<ItemFieldType*> &ItemOptionDb::getFields(const int id)
-{
- OptionInfos::const_iterator it = mOptions.find(id);
- if (it == mOptions.end())
- return mEmptyOption;
- return (*it).second;
-}
diff --git a/src/resources/db/itemoptiondb.h b/src/resources/db/itemoptiondb.h
deleted file mode 100644
index 8d9bc9968..000000000
--- a/src/resources/db/itemoptiondb.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_ITEMOPTIONDB_H
-#define RESOURCES_DB_ITEMOPTIONDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct ItemFieldType;
-
-namespace ItemOptionDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- const STD_VECTOR<ItemFieldType*> &getFields(const int id);
-
- typedef std::map<int, STD_VECTOR<ItemFieldType*> > OptionInfos;
-} // namespace ItemOptionDb
-
-#endif // RESOURCES_DB_ITEMOPTIONDB_H
diff --git a/src/resources/db/languagedb.cpp b/src/resources/db/languagedb.cpp
deleted file mode 100644
index 8d04e5c2e..000000000
--- a/src/resources/db/languagedb.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/languagedb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- std::string mDefaultIcon;
- std::string mDefaultPo;
- std::map<int, std::string> mIcons;
- std::map<int, std::string> mPo;
-} // namespace
-
-void LanguageDb::load()
-{
- unload();
- logger->log1("Initializing languages database...");
- loadXmlFile(paths.getStringValue("languagesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("languagesPatchFile"), SkipError_true);
- loadXmlDir("languagesPatchDir", loadXmlFile);
-}
-
-void LanguageDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "languages"))
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "lang"))
- {
- const int id = XML::getProperty(node, "id", -1);
- if (id < 0)
- {
- reportAlways("Missing lang id");
- continue;
- }
- const std::string icon = XML::getProperty(node, "icon", "");
- const std::string po = XML::getProperty(node, "po", "");
- if (icon.empty())
- {
- reportAlways("LanguageDb: empty icon field");
- }
- else
- {
- mIcons[id] = icon;
- }
- if (po.empty())
- {
- reportAlways("LanguageDb: empty po field");
- }
- else
- {
- mPo[id] = po;
- }
- }
- }
-
- delete doc;
-}
-
-void LanguageDb::unload()
-{
- logger->log1("Unloading languages database...");
- mIcons.clear();
- mPo.clear();
-}
-
-const std::string &LanguageDb::getIcon(const int id)
-{
- std::map<int, std::string>::const_iterator it = mIcons.find(id);
- if (it == mIcons.end())
- return mDefaultIcon;
- return (*it).second;
-}
-
-const std::string &LanguageDb::getPo(const int id)
-{
- std::map<int, std::string>::const_iterator it = mPo.find(id);
- if (it == mPo.end())
- return mDefaultPo;
- return (*it).second;
-}
diff --git a/src/resources/db/languagedb.h b/src/resources/db/languagedb.h
deleted file mode 100644
index 6b73d455e..000000000
--- a/src/resources/db/languagedb.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_LANGUAGEDB_H
-#define RESOURCES_DB_LANGUAGEDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace LanguageDb
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- const std::string &getIcon(const int id);
-
- const std::string &getPo(const int id);
-} // namespace LanguageDb
-
-#endif // RESOURCES_DB_LANGUAGEDB_H
diff --git a/src/resources/db/mapdb.cpp b/src/resources/db/mapdb.cpp
deleted file mode 100644
index 2b5dd2185..000000000
--- a/src/resources/db/mapdb.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/mapdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- MapDB::Maps mMaps;
- MapDB::MapInfos mInfos;
- MapDB::Atlases mAtlases;
-} // namespace
-
-namespace MapDB
-{
- void readMap(XmlNodePtrConst node);
- void readAtlas(XmlNodePtrConst node);
-} // namespace MapDB
-
-void MapDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing maps database...");
- loadRemapXmlFile(paths.getStringValue("mapsRemapFile"),
- SkipError_true);
- loadRemapXmlFile(paths.getStringValue("mapsRemapPatchFile"),
- SkipError_true);
- loadXmlDir("mapsRemapPatchDir", loadRemapXmlFile);
-
- loadInfo(paths.getStringValue("mapsFile"), SkipError_false);
- loadInfo(paths.getStringValue("mapsPatchFile"), SkipError_true);
- loadXmlDir("mapsPatchDir", loadInfo);
- mLoaded = true;
-}
-
-void MapDB::loadRemapXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *const doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
-
- XmlNodeConstPtrConst root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "map"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (name.empty())
- continue;
-
- const std::string value = XML::getProperty(node, "value", "");
- if (value.empty())
- continue;
-
- mMaps[name] = value;
- }
- else if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadRemapXmlFile(name, skipError);
- continue;
- }
- }
-
- delete doc;
-}
-
-void MapDB::readMap(XmlNodePtrConst node)
-{
- if (node == nullptr)
- return;
- const std::string map = XML::getProperty(node, "name", "");
- if (map.empty())
- return;
-
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "atlas"))
- {
- const std::string atlas = XML::getProperty(childNode, "name", "");
- if (atlas.empty())
- continue;
- mInfos[map].atlas = atlas;
- }
- }
-}
-
-void MapDB::readAtlas(XmlNodePtrConst node)
-{
- if (node == nullptr)
- return;
- const std::string atlas = XML::getProperty(node, "name", "");
- if (atlas.empty())
- return;
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "file"))
- {
- const std::string file = XML::getProperty(childNode, "name", "");
- if (file.empty())
- continue;
- mAtlases[atlas].push_back(file);
- }
- }
- if (atlas != "all" && atlas != paths.getStringValue("emptyAtlasName"))
- {
- const AtlasCIter &allAtlas = mAtlases.find("all");
- if (allAtlas != mAtlases.end())
- {
- FOR_EACH (StringVectCIter, it, (*allAtlas).second)
- mAtlases[atlas].push_back(*it);
- }
- }
-}
-
-void MapDB::loadInfo(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "map"))
- {
- readMap(node);
- }
- else if (xmlNameEqual(node, "atlas"))
- {
- readAtlas(node);
- }
- else if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadInfo(name, skipError);
- continue;
- }
- }
- delete doc;
-}
-
-void MapDB::unload()
-{
- logger->log1("Unloading map database...");
-
- mMaps.clear();
- mLoaded = false;
-}
-
-const std::string MapDB::getMapName(const std::string &name)
-{
- const MapIterator it = mMaps.find(name);
-
- if (it != mMaps.end())
- return it->second;
- return name;
-}
-
-const MapInfo *MapDB::getMapAtlas(const std::string &name)
-{
- const MapInfoIter it = mInfos.find(name);
- if (it == mInfos.end())
- return nullptr;
- MapInfo *const info = &(*it).second;
- const AtlasCIter it2 = mAtlases.find(info->atlas);
- if (it2 == mAtlases.end())
- return nullptr;
- info->files = &((*it2).second);
- return info;
-}
-
-const MapInfo *MapDB::getAtlas(const std::string &name)
-{
- const AtlasCIter it = mAtlases.find(name);
- if (it == mAtlases.end())
- return nullptr;
-
- MapInfo *const info = new MapInfo;
- info->atlas = name;
- info->files = &(*it).second;
- return info;
-}
diff --git a/src/resources/db/mapdb.h b/src/resources/db/mapdb.h
deleted file mode 100644
index 09cc05c03..000000000
--- a/src/resources/db/mapdb.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_MAPDB_H
-#define RESOURCES_DB_MAPDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "resources/mapinfo.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-/**
- * Color information database.
- */
-namespace MapDB
-{
- /**
- * Loads the map remap data from <code>maps\remap.xml</code>.
- */
- void load();
-
- void loadRemapXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void loadInfo(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the remap data
- */
- void unload();
-
- const std::string getMapName(const std::string &name) A_WARN_UNUSED;
-
- const MapInfo *getMapAtlas(const std::string &name) A_WARN_UNUSED;
-
- const MapInfo *getAtlas(const std::string &name) A_WARN_UNUSED;
-
- // Maps DB
- typedef std::map<std::string, std::string> Maps;
- typedef Maps::iterator MapIterator;
- // map to infos map
- typedef std::map<std::string, MapInfo> MapInfos;
- typedef MapInfos::iterator MapInfoIter;
- // atlas to files map
- typedef std::map<std::string, StringVect> Atlases;
- typedef Atlases::iterator AtlasIter;
- typedef Atlases::const_iterator AtlasCIter;
-} // namespace MapDB
-
-#endif // RESOURCES_DB_MAPDB_H
diff --git a/src/resources/db/mercenarydb.cpp b/src/resources/db/mercenarydb.cpp
deleted file mode 100644
index befbdafea..000000000
--- a/src/resources/db/mercenarydb.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/mercenarydb.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "configuration.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mMercenaryInfos;
- bool mLoaded = false;
-} // namespace
-
-void MercenaryDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing mercenary database...");
- loadXmlFile(paths.getStringValue("mercenariesFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("mercenariesPatchFile"), SkipError_true);
- loadXmlDir("mercenariesPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void MercenaryDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "mercenaries"))
- {
- logger->log("MercenaryDB: Error while loading %s!",
- paths.getStringValue("mercenariesFile").c_str());
- mLoaded = true;
- return;
- }
-
- const int offset = XML::getProperty(rootNode, "offset", 0);
-
- // iterate <mercenary>s
- for_each_xml_child_node(mercenaryNode, rootNode)
- {
- if (xmlNameEqual(mercenaryNode, "include"))
- {
- const std::string name = XML::getProperty(
- mercenaryNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (!xmlNameEqual(mercenaryNode, "mercenary"))
- continue;
-
- const int id = XML::getProperty(mercenaryNode, "id", 0);
- BeingInfo *currentInfo = nullptr;
- if (mMercenaryInfos.find(fromInt(id + offset, BeingTypeId))
- != mMercenaryInfos.end())
- {
- logger->log("MercenaryDB: Redefinition of mercenary ID %d", id);
- currentInfo = mMercenaryInfos[fromInt(id + offset, BeingTypeId)];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setBlockType(BlockType::NONE);
- currentInfo->setName(XML::langProperty(
- // TRANSLATORS: unknown info name
- mercenaryNode, "name", _("unnamed")));
- BeingCommon::readBasicAttributes(currentInfo, mercenaryNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo, mercenaryNode, 0);
- BeingCommon::readAiAttributes(currentInfo, mercenaryNode);
-
- currentInfo->setMaxHP(XML::getProperty(mercenaryNode, "maxHP", 0));
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(
- mercenaryNode, "deadSortOffsetY", 31));
-
- currentInfo->setColorsList(XML::getProperty(mercenaryNode,
- "colors", ""));
-
- if (currentInfo->getMaxHP() != 0)
- currentInfo->setStaticMaxHP(true);
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, mercenaryNode)
- {
- BeingCommon::readObjectNodes(spriteNode, display,
- currentInfo, "MonsterDB");
- }
- currentInfo->setDisplay(display);
-
- mMercenaryInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
- }
-}
-
-void MercenaryDB::unload()
-{
- logger->log1("Unloading mercenary database...");
- delete_all(mMercenaryInfos);
- mMercenaryInfos.clear();
-
- mLoaded = false;
-}
-
-
-BeingInfo *MercenaryDB::get(const BeingTypeId id)
-{
- BeingInfoIterator i = mMercenaryInfos.find(id);
-
- if (i == mMercenaryInfos.end())
- {
- i = mMercenaryInfos.find(id);
- if (i == mMercenaryInfos.end())
- {
- reportAlways("MercenaryDB: Warning, unknown mercenary ID "
- "%d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- }
- return i->second;
-}
diff --git a/src/resources/db/mercenarydb.h b/src/resources/db/mercenarydb.h
deleted file mode 100644
index 1058a8f9e..000000000
--- a/src/resources/db/mercenarydb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_MERCENARYDB_H
-#define RESOURCES_DB_MERCENARYDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingInfo;
-
-/**
- * Mercenary information database.
- */
-namespace MercenaryDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace MercenaryDB
-
-#endif // RESOURCES_DB_MERCENARYDB_H
diff --git a/src/resources/db/moddb.cpp b/src/resources/db/moddb.cpp
deleted file mode 100644
index 4e0be461f..000000000
--- a/src/resources/db/moddb.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/moddb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "resources/beingcommon.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- ModInfos mModInfos;
- bool mLoaded = false;
-} // namespace
-
-void ModDB::load()
-{
- if (mLoaded)
- unload();
- logger->log1("Initializing mod database...");
- loadXmlFile(paths.getStringValue("modsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("modsPatchFile"), SkipError_true);
- loadXmlDir("modsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void ModDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "mods"))
- {
- logger->log("Mods Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(modNode, rootNode)
- {
- if (xmlNameEqual(modNode, "include"))
- {
- const std::string name = XML::getProperty(modNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (!xmlNameEqual(modNode, "mod"))
- continue;
-
- const std::string name = XML::langProperty(
- // TRANSLATORS: unknown info name
- modNode, "name", _("unnamed"));
- ModInfo *currentInfo = nullptr;
- if (mModInfos.find(name) != mModInfos.end())
- currentInfo = mModInfos[name];
- if (currentInfo == nullptr)
- currentInfo = new ModInfo;
-
- currentInfo->setName(name);
- currentInfo->setDescription(XML::langProperty(
- modNode, "description", ""));
- currentInfo->setHelp(XML::getProperty(
- modNode, "help", ""));
- currentInfo->setLocalDir(XML::getProperty(
- modNode, "localdir", ""));
-
- mModInfos[name] = currentInfo;
- }
-}
-
-void ModDB::unload()
-{
- logger->log1("Unloading mod database...");
- delete_all(mModInfos);
- mModInfos.clear();
- mLoaded = false;
-}
-
-ModInfo *ModDB::get(const std::string &name)
-{
- const ModInfoIterator i = mModInfos.find(name);
- if (i == mModInfos.end())
- return nullptr;
- return i->second;
-}
-
-const ModInfos &ModDB::getAll()
-{
- return mModInfos;
-}
diff --git a/src/resources/db/moddb.h b/src/resources/db/moddb.h
deleted file mode 100644
index d2a009e9c..000000000
--- a/src/resources/db/moddb.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_MODDB_H
-#define RESOURCES_DB_MODDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "resources/modinfo.h"
-
-#include "localconsts.h"
-
-namespace ModDB
-{
- void load();
-
- void unload();
-
- ModInfo *get(const std::string &name) A_WARN_UNUSED;
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- const ModInfos &getAll();
-} // namespace ModDB
-
-#endif // RESOURCES_DB_MODDB_H
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
deleted file mode 100644
index b6cdc4f53..000000000
--- a/src/resources/db/monsterdb.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/monsterdb.h"
-
-#include "enums/resources/map/blockmask.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "configuration.h"
-
-#include "debug.h"
-
-static const unsigned int OLD_TMWATHENA_OFFSET = 1002;
-
-namespace
-{
- BeingInfos mMonsterInfos;
- bool mLoaded = false;
-} // namespace
-
-void MonsterDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing monster database...");
- loadXmlFile(paths.getStringValue("monstersFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("monstersPatchFile"), SkipError_true);
- loadXmlDir("monstersPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void MonsterDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "monsters"))
- {
- logger->log("Monster Database: Error while loading %s!",
- paths.getStringValue("monstersFile").c_str());
- mLoaded = true;
- return;
- }
-
- const int offset = XML::getProperty(rootNode,
- "offset", OLD_TMWATHENA_OFFSET);
-
- // iterate <monster>s
- for_each_xml_child_node(monsterNode, rootNode)
- {
- if (xmlNameEqual(monsterNode, "include"))
- {
- const std::string name = XML::getProperty(monsterNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- if (!xmlNameEqual(monsterNode, "monster"))
- continue;
-
- const int id = XML::getProperty(monsterNode, "id", 0);
- BeingInfo *currentInfo = nullptr;
- if (mMonsterInfos.find(fromInt(id + offset, BeingTypeId))
- != mMonsterInfos.end())
- {
- logger->log("MonsterDB: Redefinition of monster ID %d", id);
- currentInfo = mMonsterInfos[fromInt(id + offset, BeingTypeId)];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setBlockType(BlockType::NONE);
- currentInfo->setName(XML::langProperty(
- // TRANSLATORS: unknown info name
- monsterNode, "name", _("unnamed")));
-
- BeingCommon::readBasicAttributes(currentInfo, monsterNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo, monsterNode,
- BlockMask::MONSTERWALL);
-
- currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0));
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(
- monsterNode, "deadSortOffsetY", 31));
-
- currentInfo->setColorsList(XML::getProperty(monsterNode,
- "colors", ""));
-
- if (currentInfo->getMaxHP() != 0)
- currentInfo->setStaticMaxHP(true);
-
- SpriteDisplay display;
-
- // iterate <sprite>s and <sound>s
- for_each_xml_child_node(spriteNode, monsterNode)
- {
- BeingCommon::readObjectNodes(spriteNode, display,
- currentInfo, "MonsterDB");
- }
- currentInfo->setDisplay(display);
-
- mMonsterInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
- }
-}
-
-void MonsterDB::unload()
-{
- logger->log1("Unloading monster database...");
- delete_all(mMonsterInfos);
- mMonsterInfos.clear();
-
- mLoaded = false;
-}
-
-
-BeingInfo *MonsterDB::get(const BeingTypeId id)
-{
- BeingInfoIterator i = mMonsterInfos.find(id);
-
- if (i == mMonsterInfos.end())
- {
- i = mMonsterInfos.find(fromInt(toInt(
- id, int) + OLD_TMWATHENA_OFFSET, BeingTypeId));
- if (i == mMonsterInfos.end())
- {
- reportAlways("MonsterDB: Warning, unknown monster ID %d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- }
- return i->second;
-}
diff --git a/src/resources/db/monsterdb.h b/src/resources/db/monsterdb.h
deleted file mode 100644
index 076814e9d..000000000
--- a/src/resources/db/monsterdb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_MONSTERDB_H
-#define RESOURCES_DB_MONSTERDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingInfo;
-
-/**
- * Monster information database.
- */
-namespace MonsterDB
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace MonsterDB
-
-#endif // RESOURCES_DB_MONSTERDB_H
diff --git a/src/resources/db/networkdb.cpp b/src/resources/db/networkdb.cpp
deleted file mode 100644
index 4ad9eb222..000000000
--- a/src/resources/db/networkdb.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/networkdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/xmlutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- NetworkInPacketInfos mInPackets;
- NetworkRemovePacketInfos mRemovePackets;
-} // namespace
-
-void NetworkDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing network database...");
- loadXmlFile(paths.getStringValue("networkFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("networkPatchFile"), SkipError_true);
- loadXmlDir("networkPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void NetworkDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- readXmlIntMap(fileName,
- "network",
- "inpackets",
- "fakepacket",
- "id",
- "len",
- mInPackets,
- skipError);
-
- readXmlIntVector(fileName,
- "network",
- "inpackets",
- "removepacket",
- "id",
- mRemovePackets,
- skipError);
-}
-
-void NetworkDb::unload()
-{
- logger->log1("Unloading network database...");
- mInPackets.clear();
- mRemovePackets.clear();
- mLoaded = false;
-}
-
-const NetworkInPacketInfos &NetworkDb::getFakePackets()
-{
- return mInPackets;
-}
-
-const NetworkRemovePacketInfos &NetworkDb::getRemovePackets()
-{
- return mRemovePackets;
-}
diff --git a/src/resources/db/networkdb.h b/src/resources/db/networkdb.h
deleted file mode 100644
index 0541f9c1f..000000000
--- a/src/resources/db/networkdb.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_NETWORKDB_H
-#define RESOURCES_DB_NETWORKDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include <map>
-#include <string>
-
-typedef std::map<int32_t, int32_t> NetworkInPacketInfos;
-typedef NetworkInPacketInfos::const_iterator NetworkInPacketInfosIter;
-typedef STD_VECTOR<int> NetworkRemovePacketInfos;
-typedef NetworkRemovePacketInfos::const_iterator NetworkRemovePacketInfosIter;
-
-namespace NetworkDb
-{
- /**
- * Loads the chars data.
- */
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the chars data
- */
- void unload();
-
- const NetworkInPacketInfos &getFakePackets();
-
- const NetworkRemovePacketInfos &getRemovePackets();
-} // namespace NetworkDb
-
-#endif // RESOURCES_DB_NETWORKDB_H
diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp
deleted file mode 100644
index 26034de12..000000000
--- a/src/resources/db/npcdb.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/npcdb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mNPCInfos;
- bool mLoaded = false;
-} // namespace
-
-void NPCDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing NPC database...");
-
- loadXmlFile(paths.getStringValue("npcsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("npcsPatchFile"), SkipError_true);
- loadXmlDir("npcsPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void NPCDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "npcs"))
- {
- logger->log("NPC Database: Error while loading %s!",
- paths.getStringValue("npcsFile").c_str());
- mLoaded = true;
- return;
- }
-
- // iterate <npc>s
- for_each_xml_child_node(npcNode, rootNode)
- {
- if (xmlNameEqual(npcNode, "include"))
- {
- const std::string name = XML::getProperty(npcNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
-
- if (!xmlNameEqual(npcNode, "npc"))
- continue;
-
- const BeingTypeId id = fromInt(XML::getProperty(
- npcNode, "id", 0), BeingTypeId);
- BeingInfo *currentInfo = nullptr;
- if (id == BeingTypeId_zero)
- {
- reportAlways("NPC Database: NPC with missing ID in %s!",
- paths.getStringValue("npcsFile").c_str());
- continue;
- }
- else if (mNPCInfos.find(id) != mNPCInfos.end())
- {
- logger->log("NpcDB: Redefinition of npc ID %d", toInt(id, int));
- currentInfo = mNPCInfos[id];
- }
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setTargetSelection(XML::getBoolProperty(npcNode,
- "targetSelection", true));
-
- BeingCommon::readBasicAttributes(currentInfo, npcNode, "talk");
- BeingCommon::readWalkingAttributes(currentInfo, npcNode, 0);
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(npcNode,
- "deadSortOffsetY", 31));
-
- currentInfo->setAvatarId(fromInt(XML::getProperty(
- npcNode, "avatar", 0), BeingTypeId));
-
- currentInfo->setAllowDelete(XML::getBoolProperty(npcNode,
- "allowDelete", true));
-
- const std::string currency = XML::getProperty(npcNode,
- "currency", "default");
- if (UnitsDb::existsCurrency(currency) == false)
- {
- reportAlways("Not found currency '%s' for npc %d",
- currency.c_str(),
- CAST_S32(id));
- }
- currentInfo->setCurrency(currency);
-
- SpriteDisplay display;
- for_each_xml_child_node(spriteNode, npcNode)
- {
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant =
- XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- display.particles.push_back(XmlChildContent(spriteNode));
- }
- else if (xmlNameEqual(spriteNode, "menu"))
- {
- std::string name = XML::langProperty(spriteNode, "name", "");
- std::string command = XML::getProperty(spriteNode,
- "command", "");
- currentInfo->addMenu(name, command);
- }
- }
-
- currentInfo->setDisplay(display);
- if (currentInfo->getMenu().empty())
- {
- // TRANSLATORS: npc context menu item
- currentInfo->addMenu(_("Talk"), "talk 'NAME'");
- // TRANSLATORS: npc context menu item
- currentInfo->addMenu(_("Buy"), "buy 'NAME'");
- // TRANSLATORS: npc context menu item
- currentInfo->addMenu(_("Sell"), "sell 'NAME'");
- }
- mNPCInfos[id] = currentInfo;
- }
-}
-
-void NPCDB::unload()
-{
- logger->log1("Unloading NPC database...");
- delete_all(mNPCInfos);
- mNPCInfos.clear();
-
- mLoaded = false;
-}
-
-BeingInfo *NPCDB::get(const BeingTypeId id)
-{
- const BeingInfoIterator i = mNPCInfos.find(id);
-
- if (i == mNPCInfos.end())
- {
- reportAlways("NPCDB: Warning, unknown NPC ID %d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- return i->second;
-}
-
-BeingTypeId NPCDB::getAvatarFor(const BeingTypeId id)
-{
- const BeingInfo *const info = get(id);
- if (info == nullptr)
- return BeingTypeId_zero;
- return info->getAvatarId();
-}
diff --git a/src/resources/db/npcdb.h b/src/resources/db/npcdb.h
deleted file mode 100644
index 248bd6039..000000000
--- a/src/resources/db/npcdb.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_NPCDB_H
-#define RESOURCES_DB_NPCDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class BeingInfo;
-
-/**
- * NPC information database.
- */
-namespace NPCDB
-{
- void load();
-
- void unload();
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-
- BeingTypeId getAvatarFor(const BeingTypeId id);
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-} // namespace NPCDB
-
-#endif // RESOURCES_DB_NPCDB_H
diff --git a/src/resources/db/npcdialogdb.cpp b/src/resources/db/npcdialogdb.cpp
deleted file mode 100644
index 9d6825bfa..000000000
--- a/src/resources/db/npcdialogdb.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/npcdialogdb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/npcdialoginfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- NpcDialogDB::Dialogs mDialogs;
-} // namespace
-
-void NpcDialogDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Loading npc dialog database...");
- loadXmlFile(paths.getStringValue("npcDialogsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("npcDialogsPatchFile"), SkipError_true);
- loadXmlDir("npcDialogsPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-static void loadNpcDialogMenu(NpcDialogInfo *const dialog,
- XmlNodeConstPtrConst node)
-{
- for_each_xml_child_node(childNode, node)
- {
- if (!xmlTypeEqual(childNode, XML_ELEMENT_NODE))
- continue;
-
- if (xmlNameEqual(childNode, "button"))
- {
- const std::string name = XML::getProperty(childNode, "name", "");
- const std::string value = XML::getProperty(childNode, "value", "");
- if (value.empty())
- continue;
-
- NpcButtonInfo *const button = new NpcButtonInfo;
- button->x = XML::getIntProperty(
- childNode, "x", 0, 0, 10000);
- button->y = XML::getIntProperty(
- childNode, "y", 0, 0, 10000);
- button->name = name;
- button->value = value;
- button->image = XML::getProperty(childNode, "image", "");
- if (button->name.empty() && button->image.empty())
- {
- reportAlways("Error: npc button without name or image");
- delete button;
- continue;
- }
- button->imageWidth = XML::getIntProperty(
- childNode, "imageWidth", 16, 1, 1000);
- button->imageHeight = XML::getIntProperty(
- childNode, "imageHeight", 16, 1, 1000);
- dialog->menu.buttons.push_back(button);
- }
- else if (xmlNameEqual(childNode, "image"))
- {
- const std::string image = XML::getProperty(childNode, "image", "");
- if (image.empty())
- {
- reportAlways("Error: no image attribute found in image tag.");
- continue;
- }
- NpcImageInfo *const imageInfo = new NpcImageInfo;
- imageInfo->name = image;
- imageInfo->x = XML::getIntProperty(
- childNode, "x", 0, 0, 10000);
- imageInfo->y = XML::getIntProperty(
- childNode, "y", 0, 0, 10000);
- dialog->menu.images.push_back(imageInfo);
- }
- else if (xmlNameEqual(childNode, "text"))
- {
- const std::string text = XML::getProperty(childNode, "text", "");
- if (text.empty())
- {
- reportAlways("Error: no text attribute found in text tag.");
- continue;
- }
- NpcTextInfo *const textInfo = new NpcTextInfo;
- textInfo->text = text;
- textInfo->x = XML::getIntProperty(
- childNode, "x", 0, 0, 10000);
- textInfo->y = XML::getIntProperty(
- childNode, "y", 0, 0, 10000);
- textInfo->width = XML::getIntProperty(
- childNode, "width", 20, 10, 10000);
- textInfo->height = XML::getIntProperty(
- childNode, "height", 20, 10, 10000);
- dialog->menu.texts.push_back(textInfo);
- }
- }
-}
-
-static void loadNpcDialogInventory(NpcDialogInfo *const dialog,
- XmlNodePtrConst node)
-{
- dialog->inventory.cell = XML::getProperty(node, "cell", "");
- dialog->inventory.columns = XML::getIntProperty(
- node, "columns", 10000, 1, 10000);
-}
-
-static void loadNpcDialog(NpcDialogInfo *const dialog,
- XmlNodeConstPtrConst node)
-{
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "menu"))
- {
- loadNpcDialogMenu(dialog, childNode);
- }
- else if (xmlNameEqual(childNode, "inventory"))
- {
- loadNpcDialogInventory(dialog, childNode);
- }
- }
-}
-
-void NpcDialogDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *const doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
-
- XmlNodeConstPtrConst root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "dialog"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (name.empty())
- continue;
-
- deleteDialog(name);
- NpcDialogInfo *const dialog = new NpcDialogInfo;
- dialog->name = name;
- dialog->hideText = XML::getBoolProperty(
- node, "hideText", false);
- mDialogs[name] = dialog;
- loadNpcDialog(dialog, node);
- }
- else if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- }
-
- delete doc;
-}
-
-void NpcDialogDB::deleteDialog(const std::string &name)
-{
- const DialogsIter it = mDialogs.find(name);
- if (it == mDialogs.end())
- return;
-
- NpcDialogInfo *dialog = (*it).second;
- delete_all(dialog->menu.buttons);
- delete_all(dialog->menu.images);
- delete_all(dialog->menu.texts);
- mDialogs.erase(it);
- delete dialog;
-}
-
-void NpcDialogDB::unload()
-{
- logger->log1("Unloading npc dialog database...");
-
- FOR_EACH (DialogsIter, it, mDialogs)
- {
- NpcDialogInfo *dialog = (*it).second;
- delete_all(dialog->menu.buttons);
- delete_all(dialog->menu.images);
- delete_all(dialog->menu.texts);
- delete dialog;
- }
- mDialogs.clear();
-
- mLoaded = false;
-}
-
-NpcDialogInfo *NpcDialogDB::getDialog(const std::string &name)
-{
- const DialogsIter it = mDialogs.find(name);
- if (it == mDialogs.end())
- return nullptr;
- return (*it).second;
-}
diff --git a/src/resources/db/npcdialogdb.h b/src/resources/db/npcdialogdb.h
deleted file mode 100644
index 8e6e241af..000000000
--- a/src/resources/db/npcdialogdb.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_NPCDIALOGDB_H
-#define RESOURCES_DB_NPCDIALOGDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct NpcDialogInfo;
-
-/**
- * Color information database.
- */
-namespace NpcDialogDB
-{
- /**
- * Loads the map remap data from <code>maps\remap.xml</code>.
- */
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Clear the remap data
- */
- void unload();
-
- void deleteDialog(const std::string &name);
-
- NpcDialogInfo *getDialog(const std::string &name);
-
- typedef std::map<std::string, NpcDialogInfo*> Dialogs;
- typedef Dialogs::iterator DialogsIter;
-
-} // namespace NpcDialogDB
-
-#endif // RESOURCES_DB_NPCDIALOGDB_H
diff --git a/src/resources/db/palettedb.cpp b/src/resources/db/palettedb.cpp
deleted file mode 100644
index d7ec6b78d..000000000
--- a/src/resources/db/palettedb.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/palettedb.h"
-
-#include "configuration.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/dye/dyecolor.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- std::map<std::string, DyeColor> mColors;
-} // namespace
-
-void PaletteDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing palette database...");
- loadPalette();
-}
-
-void PaletteDB::loadPalette()
-{
- mLoaded = true;
- StringVect lines;
- VirtFs::loadTextFile(paths.getStringValue("palettesDir") +
- paths.getStringValue("defaultPaletteFile"),
- lines);
- StringVectCIter it = lines.begin();
- if (it == lines.end())
- {
- logger->log("missing GIMP palette file");
- return;
- }
- if (*it != "GIMP Palette")
- {
- reportAlways("wrong GIMP palette file");
- return;
- }
- ++ it;
- // skip header
- while (it != lines.end())
- {
- const std::string line = *it;
- if (!line.empty() && line[0] == '#')
- break;
- ++ it;
- }
-
- char name[101];
-
- // process colors and ignore commets
- while (it != lines.end())
- {
- const std::string line = *it;
- ++ it;
-
- if (line.empty() || line[0] == '#')
- continue;
-
- unsigned int r;
- unsigned int g;
- unsigned int b;
-
- if (sscanf(line.c_str(), "%10u %10u %10u\t%100s",
- &r, &g, &b, name) == 4)
- {
- name[100] = 0;
- mColors[name] = DyeColor(CAST_U8(r),
- CAST_U8(g),
- CAST_U8(b));
- }
- }
-}
-
-void PaletteDB::unload()
-{
- logger->log1("Unloading palette database...");
- mColors.clear();
-}
-
-const DyeColor *PaletteDB::getColor(const std::string &name)
-{
- const std::map<std::string, DyeColor>::const_iterator it =
- mColors.find(name);
- if (it != mColors.end())
- return &(*it).second;
- return nullptr;
-}
diff --git a/src/resources/db/palettedb.h b/src/resources/db/palettedb.h
deleted file mode 100644
index 2dc54eb53..000000000
--- a/src/resources/db/palettedb.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_PALETTEDB_H
-#define RESOURCES_DB_PALETTEDB_H
-
-#include "localconsts.h"
-
-#include <string>
-
-struct DyeColor;
-
-namespace PaletteDB
-{
- void load();
- void unload();
- void loadPalette();
- const DyeColor *getColor(const std::string &name);
-
-} // namespace PaletteDB
-
-#endif // RESOURCES_DB_PALETTEDB_H
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
deleted file mode 100644
index 721b27bfb..000000000
--- a/src/resources/db/petdb.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/petdb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mPETInfos;
- bool mLoaded = false;
-} // namespace
-
-void PETDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing PET database...");
- loadXmlFile(paths.getStringValue("petsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("petsPatchFile"), SkipError_true);
- loadXmlDir("petsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void PETDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "pets"))
- {
- logger->log("PET Database: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- // iterate <pet>s
- for_each_xml_child_node(petNode, rootNode)
- {
- if (xmlNameEqual(petNode, "include"))
- {
- const std::string name = XML::getProperty(petNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(petNode, "pet"))
- {
- continue;
- }
-
- const BeingTypeId id = fromInt(XML::getProperty(
- petNode, "id", -1), BeingTypeId);
- if (id == BeingTypeId_negOne)
- {
- reportAlways("PET Database: PET with missing ID in %s!",
- paths.getStringValue("petsFile").c_str());
- continue;
- }
-
- BeingInfo *currentInfo = nullptr;
- if (mPETInfos.find(id) != mPETInfos.end())
- currentInfo = mPETInfos[id];
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setName(XML::langProperty(petNode,
- // TRANSLATORS: unknown info name
- "name", _("pet")));
-
- currentInfo->setTargetSelection(XML::getBoolProperty(petNode,
- "targetSelection", true));
-
- BeingCommon::readBasicAttributes(currentInfo, petNode, "talk");
- BeingCommon::readWalkingAttributes(currentInfo, petNode, 0);
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(petNode,
- "deadSortOffsetY", 31));
-
- const std::string returnMessage = XML::langProperty(petNode,
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pet return to egg
- "removeMessage", _("Return to egg"));
- currentInfo->setString(0, returnMessage);
-
- SpriteDisplay display;
- for_each_xml_child_node(spriteNode, petNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant =
- XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- std::string particlefx = XmlChildContent(spriteNode);
- display.particles.push_back(particlefx);
- }
- }
-
- currentInfo->setDisplay(display);
-
- mPETInfos[id] = currentInfo;
- }
-}
-
-void PETDB::unload()
-{
- logger->log1("Unloading PET database...");
- delete_all(mPETInfos);
- mPETInfos.clear();
-
- mLoaded = false;
-}
-
-BeingInfo *PETDB::get(const BeingTypeId id)
-{
- const BeingInfoIterator i = mPETInfos.find(id);
-
- if (i == mPETInfos.end())
- {
- reportAlways("PETDB: Warning, unknown PET ID %d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- return i->second;
-}
diff --git a/src/resources/db/petdb.h b/src/resources/db/petdb.h
deleted file mode 100644
index 05d79d3eb..000000000
--- a/src/resources/db/petdb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_PETDB_H
-#define RESOURCES_DB_PETDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class BeingInfo;
-
-namespace PETDB
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace PETDB
-
-#endif // RESOURCES_DB_PETDB_H
diff --git a/src/resources/db/questdb.cpp b/src/resources/db/questdb.cpp
deleted file mode 100644
index d932b656e..000000000
--- a/src/resources/db/questdb.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/questdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "utils/translation/podict.h"
-
-#include "resources/beingcommon.h"
-#include "resources/questeffect.h"
-#include "resources/questitem.h"
-
-#include "debug.h"
-
-namespace
-{
- // quest variables: var, (val1, val2, val3, time)
- NpcQuestVarMap mVars;
- // quests: var, quests
- std::map<int, STD_VECTOR<QuestItem*> > mQuests;
- STD_VECTOR<QuestEffect*> mAllEffects;
-} // namespace
-
-void QuestDb::load()
-{
- unload();
- logger->log1("Initializing quest database...");
- loadXmlFile(paths.getStringValue("questsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("questsPatchFile"), SkipError_true);
- loadXmlDir("questsPatchDir", loadXmlFile);
-}
-
-static void loadQuest(const int var,
- XmlNodeConstPtr node)
-{
- if (node == nullptr)
- return;
- QuestItem *const quest = new QuestItem;
- // TRANSLATORS: quests window quest name
- quest->name = XML::langProperty(node, "name", _("unknown"));
- quest->group = XML::getProperty(node, "group", "");
- std::string incompleteStr = XML::getProperty(node, "incomplete", "");
- std::string completeStr = XML::getProperty(node, "complete", "");
- if (incompleteStr.empty() && completeStr.empty())
- {
- logger->log("complete flags incorrect");
- delete quest;
- return;
- }
- splitToIntSet(quest->incomplete, incompleteStr, ',');
- splitToIntSet(quest->complete, completeStr, ',');
- if (quest->incomplete.empty() && quest->complete.empty())
- {
- logger->log("complete flags incorrect");
- delete quest;
- return;
- }
- if (quest->incomplete.empty() || quest->complete.empty())
- quest->broken = true;
-
- for_each_xml_child_node(dataNode, node)
- {
- if (!xmlTypeEqual(dataNode, XML_ELEMENT_NODE))
- continue;
- XmlChar *const data = reinterpret_cast<XmlChar*>(
- XmlNodeGetContent(dataNode));
- if (data == nullptr)
- continue;
- std::string str = translator->getStr(data);
- XmlFree(data);
-
- for (int f = 1; f < 100; f ++)
- {
- const std::string key = strprintf("text%d", f);
- const std::string val = XML::getProperty(dataNode,
- key.c_str(),
- "");
- if (val.empty())
- break;
- const std::string param = strprintf("{@@%d}", f);
- replaceAll(str, param, val);
- }
- replaceItemLinks(str);
- if (xmlNameEqual(dataNode, "text"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::TEXT,
- std::string(),
- std::string()));
- }
- else if (xmlNameEqual(dataNode, "name"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::NAME,
- std::string(),
- std::string()));
- }
- else if (xmlNameEqual(dataNode, "reward"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::REWARD,
- std::string(),
- std::string()));
- }
- else if (xmlNameEqual(dataNode, "questgiver") ||
- xmlNameEqual(dataNode, "giver"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::GIVER,
- std::string(),
- std::string()));
- }
- else if (xmlNameEqual(dataNode, "coordinates"))
- {
- const std::string str1 = toString(XML::getIntProperty(
- dataNode, "x", 0, 1, 1000));
- const std::string str2 = toString(XML::getIntProperty(
- dataNode, "y", 0, 1, 1000));
- quest->texts.push_back(QuestItemText(str,
- QuestType::COORDINATES,
- str1,
- str2));
- }
- else if (xmlNameEqual(dataNode, "npc"))
- {
- quest->texts.push_back(QuestItemText(str,
- QuestType::NPC,
- std::string(),
- std::string()));
- }
- }
- quest->var = var;
- mQuests[var].push_back(quest);
-}
-
-static void loadEffect(const int var,
- XmlNodeConstPtr node)
-{
- QuestEffect *const effect = new QuestEffect;
- effect->map = XML::getProperty(node, "map", "");
- effect->id = fromInt(XML::getProperty(node, "npc", -1), BeingTypeId);
- effect->effectId = XML::getProperty(node, "effect", -1);
- const std::string values = XML::getProperty(node, "value", "");
- splitToIntSet(effect->values, values, ',');
-
- if (effect->map.empty() || effect->id == BeingTypeId_negOne
- || effect->effectId == -1 || values.empty())
- {
- delete effect;
- return;
- }
- effect->var = var;
- mAllEffects.push_back(effect);
-}
-
-void QuestDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc.rootNode();
- if (root == nullptr)
- return;
-
- for_each_xml_child_node(varNode, root)
- {
- if (xmlNameEqual(varNode, "include"))
- {
- const std::string name = XML::getProperty(varNode, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(varNode, "var"))
- {
- const int id = XML::getProperty(varNode, "id", 0);
- if (id < 0)
- continue;
- mVars[id] = QuestVar();
- for_each_xml_child_node(questNode, varNode)
- {
- if (xmlNameEqual(questNode, "quest"))
- loadQuest(id, questNode);
- else if (xmlNameEqual(questNode, "effect"))
- loadEffect(id, questNode);
- }
- }
- }
-}
-
-
-void QuestDb::unload()
-{
- logger->log1("Unloading quest database...");
- for (std::map<int, STD_VECTOR<QuestItem*> >::iterator it
- = mQuests.begin(), it_end = mQuests.end(); it != it_end; ++ it)
- {
- STD_VECTOR<QuestItem*> &quests = (*it).second;
- for (STD_VECTOR<QuestItem*>::iterator it2 = quests.begin(),
- it2_end = quests.end(); it2 != it2_end; ++ it2)
- {
- delete *it2;
- }
- }
- delete_all(mAllEffects);
- mAllEffects.clear();
- mQuests.clear();
-}
-
-NpcQuestVarMap *QuestDb::getVars()
-{
- return &mVars;
-}
-
-std::map<int, STD_VECTOR<QuestItem*> > *QuestDb::getQuests()
-{
- return &mQuests;
-}
-
-STD_VECTOR<QuestEffect*> *QuestDb::getAllEffects()
-{
- return &mAllEffects;
-}
-
-std::string QuestDb::getName(const int id)
-{
- std::map<int, STD_VECTOR<QuestItem*> >::const_iterator it =
- mQuests.find(id);
- if (it == mQuests.end())
- {
- // TRANSLATORS: quests window quest name
- return _("unknown");
- }
- const STD_VECTOR<QuestItem*> &items = (*it).second;
- if (items.empty())
- {
- // TRANSLATORS: quests window quest name
- return _("unknown");
- }
- return items[0]->name;
-}
diff --git a/src/resources/db/questdb.h b/src/resources/db/questdb.h
deleted file mode 100644
index 865f917fe..000000000
--- a/src/resources/db/questdb.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_QUESTDB_H
-#define RESOURCES_DB_QUESTDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include "resources/questvar.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct QuestEffect;
-struct QuestItem;
-
-namespace QuestDb
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- NpcQuestVarMap *getVars();
-
- std::map<int, STD_VECTOR<QuestItem*> > *getQuests();
-
- STD_VECTOR<QuestEffect*> *getAllEffects();
-
- std::string getName(const int id);
-} // namespace QuestDb
-
-#endif // RESOURCES_DB_QUESTDB_H
diff --git a/src/resources/db/skillunitdb.cpp b/src/resources/db/skillunitdb.cpp
deleted file mode 100644
index 0150c4a16..000000000
--- a/src/resources/db/skillunitdb.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/skillunitdb.h"
-
-#include "configuration.h"
-
-#include "resources/beingcommon.h"
-#include "resources/beinginfo.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- BeingInfos mSkillUnitInfos;
- bool mLoaded = false;
-} // namespace
-
-void SkillUnitDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing skill unit database...");
- loadXmlFile(paths.getStringValue("skillUnitsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("skillUnitsPatchFile"), SkipError_true);
- loadXmlDir("skillUnitsPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-void SkillUnitDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "skillunits"))
- {
- logger->log("SkillUnitDb: Error while loading %s!",
- fileName.c_str());
- return;
- }
-
- // iterate <skillunit>s
- for_each_xml_child_node(skillUnitNode, rootNode)
- {
- if (xmlNameEqual(skillUnitNode, "include"))
- {
- const std::string name = XML::getProperty(skillUnitNode,
- "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (!xmlNameEqual(skillUnitNode, "skillunit"))
- {
- continue;
- }
-
- const BeingTypeId id = fromInt(XML::getProperty(
- skillUnitNode, "id", -1), BeingTypeId);
- if (id == BeingTypeId_negOne)
- {
- reportAlways("SkillUnitDb: skill unit with missing ID in %s!",
- paths.getStringValue("skillUnitsFile").c_str());
- continue;
- }
-
- BeingInfo *currentInfo = nullptr;
- if (mSkillUnitInfos.find(id) != mSkillUnitInfos.end())
- currentInfo = mSkillUnitInfos[id];
- if (currentInfo == nullptr)
- currentInfo = new BeingInfo;
-
- currentInfo->setName(XML::langProperty(skillUnitNode,
- // TRANSLATORS: unknown info name
- "name", _("skill")));
-
- currentInfo->setTargetSelection(XML::getBoolProperty(skillUnitNode,
- "targetSelection", true));
-
- BeingCommon::readBasicAttributes(currentInfo, skillUnitNode, "attack");
- BeingCommon::readWalkingAttributes(currentInfo, skillUnitNode, 0);
-
- currentInfo->setDeadSortOffsetY(XML::getProperty(skillUnitNode,
- "deadSortOffsetY", 31));
-
- SpriteDisplay display;
- for_each_xml_child_node(spriteNode, skillUnitNode)
- {
- if (!XmlHaveChildContent(spriteNode))
- continue;
-
- if (xmlNameEqual(spriteNode, "sprite"))
- {
- SpriteReference *const currentSprite = new SpriteReference;
- currentSprite->sprite = XmlChildContent(spriteNode);
- currentSprite->variant =
- XML::getProperty(spriteNode, "variant", 0);
- display.sprites.push_back(currentSprite);
- }
- else if (xmlNameEqual(spriteNode, "particlefx"))
- {
- std::string particlefx = XmlChildContent(spriteNode);
- display.particles.push_back(particlefx);
- }
- }
-
- currentInfo->setDisplay(display);
-
- mSkillUnitInfos[id] = currentInfo;
- }
-}
-
-void SkillUnitDb::unload()
-{
- logger->log1("Unloading skill unit database...");
- delete_all(mSkillUnitInfos);
- mSkillUnitInfos.clear();
-
- mLoaded = false;
-}
-
-BeingInfo *SkillUnitDb::get(const BeingTypeId id)
-{
- const BeingInfoIterator i = mSkillUnitInfos.find(id);
-
- if (i == mSkillUnitInfos.end())
- {
- reportAlways("SkillUnitDb: Warning, unknown skill unit id "
- "%d requested",
- toInt(id, int));
- return BeingInfo::unknown;
- }
- return i->second;
-}
diff --git a/src/resources/db/skillunitdb.h b/src/resources/db/skillunitdb.h
deleted file mode 100644
index cdbd5354a..000000000
--- a/src/resources/db/skillunitdb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_SKILLUNITDB_H
-#define RESOURCES_DB_SKILLUNITDB_H
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class BeingInfo;
-
-namespace SkillUnitDb
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- BeingInfo *get(const BeingTypeId id) A_WARN_UNUSED;
-} // namespace SkillUnitDb
-
-#endif // RESOURCES_DB_SKILLUNITDB_H
diff --git a/src/resources/db/sounddb.cpp b/src/resources/db/sounddb.cpp
deleted file mode 100644
index 7c9ecbdd0..000000000
--- a/src/resources/db/sounddb.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/sounddb.h"
-
-#include "configuration.h"
-#include "logger.h"
-#include "notifymanager.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- std::string mDefault;
- STD_VECTOR<std::string> mSounds;
-} // namespace
-
-void SoundDB::load()
-{
- unload();
- logger->log1("Initializing sound database...");
- loadXmlFile(paths.getStringValue("soundsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("soundsPatchFile"), SkipError_true);
- loadXmlDir("soundsPatchDir", loadXmlFile);
-}
-
-void SoundDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "sounds"))
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "sound"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- const int id = NotifyManager::getIndexBySound(name);
- if (id != 0)
- {
- const std::string value = XML::getProperty(node, "value", "");
- mSounds[id] = value;
- }
- }
- }
-
- delete doc;
-}
-
-void SoundDB::unload()
-{
- logger->log1("Unloading sound database...");
- mSounds.resize(NotifyTypes::TYPE_END);
- for (int f = 0; f < NotifyTypes::TYPE_END; f ++)
- mSounds[f].clear();
-}
-
-std::string &SoundDB::getSound(const int id)
-{
- if (id < 0 || id >= NotifyTypes::TYPE_END)
- return mDefault;
- return mSounds[id];
-}
diff --git a/src/resources/db/sounddb.h b/src/resources/db/sounddb.h
deleted file mode 100644
index dc6dddb0b..000000000
--- a/src/resources/db/sounddb.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_SOUNDDB_H
-#define RESOURCES_DB_SOUNDDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace SoundDB
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- std::string &getSound(const int id);
-} // namespace SoundDB
-
-#endif // RESOURCES_DB_SOUNDDB_H
diff --git a/src/resources/db/statdb.cpp b/src/resources/db/statdb.cpp
deleted file mode 100644
index 08fef09d6..000000000
--- a/src/resources/db/statdb.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/statdb.h"
-
-#include "configuration.h"
-
-#include "enums/being/attributesstrings.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace
-{
- bool mLoaded = false;
- STD_VECTOR<BasicStat> mBasicStats;
- std::map<std::string, STD_VECTOR<BasicStat> > mStats;
- STD_VECTOR<std::string> mPages;
-} // namespace
-
-void StatDb::addDefaultStats()
-{
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_STR,
- "str",
- // TRANSLATORS: player stat
- _("Strength")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_AGI,
- "agi",
- // TRANSLATORS: player stat
- _("Agility")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_VIT,
- "vit",
- // TRANSLATORS: player stat
- _("Vitality")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_INT,
- "int",
- // TRANSLATORS: player stat
- _("Intelligence")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_DEX,
- "dex",
- // TRANSLATORS: player stat
- _("Dexterity")));
- mBasicStats.push_back(BasicStat(Attributes::PLAYER_LUK,
- "luk",
- // TRANSLATORS: player stat
- _("Luck")));
-}
-
-const STD_VECTOR<BasicStat> &StatDb::getBasicStats()
-{
- return mBasicStats;
-}
-
-const STD_VECTOR<BasicStat> &StatDb::getStats(const std::string &page)
-{
- return mStats[page];
-}
-
-const STD_VECTOR<std::string> &StatDb::getPages()
-{
- return mPages;
-}
-
-void StatDb::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing stat database...");
-
- loadXmlFile(paths.getStringValue("statFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("statPatchFile"), SkipError_true);
- loadXmlDir("statPatchDir", loadXmlFile);
- mLoaded = true;
-}
-
-static void loadBasicStats(XmlNodeConstPtr rootNode)
-{
- const int maxAttr = static_cast<int>(Attributes::MAX_ATTRIBUTE);
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "stat"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- const std::string attr = XML::getProperty(node, "attr", "");
- if (attr.empty() || AttributesEnum::find(attr) == false)
- {
- const int id = XML::getProperty(node, "id", 0);
- if (id <= 0 || id >= maxAttr)
- {
- reportAlways("Wrong attr or id for basic "
- "stat with name %s",
- name.c_str());
- continue;
- }
- const std::string tag = XML::getProperty(node, "tag", "");
- mBasicStats.push_back(BasicStat(static_cast<AttributesT>(id),
- tag,
- name));
- }
- else
- {
- const std::string tag = XML::getProperty(node, "tag", "");
- mBasicStats.push_back(BasicStat(AttributesEnum::get(attr),
- tag,
- name));
- }
- }
- }
-}
-
-static void loadStats(XmlNodeConstPtr rootNode,
- const std::string &page)
-{
- const int maxAttr = static_cast<int>(Attributes::MAX_ATTRIBUTE);
- STD_VECTOR<BasicStat> &stats = mStats[page];
- mPages.push_back(page);
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "stat"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- const std::string attr = XML::getProperty(node, "attr", "");
- if (attr.empty() || AttributesEnum::find(attr) == false)
- {
- const int id = XML::getProperty(node, "id", 0);
- if (id <= 0 || id >= maxAttr)
- {
- reportAlways("Wrong attr or id for extended "
- "stat with name %s",
- name.c_str());
- continue;
- }
- stats.push_back(BasicStat(static_cast<AttributesT>(id),
- std::string(),
- name));
- }
- else
- {
- stats.push_back(BasicStat(AttributesEnum::get(attr),
- std::string(),
- name));
- }
- }
- }
-}
-
-void StatDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "stats"))
- {
- logger->log("StatDb: Error while loading %s!",
- fileName.c_str());
- if (skipError == SkipError_false)
- addDefaultStats();
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "basic"))
- {
- loadBasicStats(node);
- }
- else if (xmlNameEqual(node, "extended"))
- {
- // TRANSLATORS: stats page name
- loadStats(node, _("Extended"));
- }
- else if (xmlNameEqual(node, "page"))
- {
- std::string page = XML::langProperty(node, "name", "");
- if (page.empty())
- {
- reportAlways("Page without name in stats.xml");
- page = "Unknown";
- }
- loadStats(node, page);
- }
- }
- if (skipError == SkipError_false)
- {
- if (mBasicStats.empty() &&
- mStats.empty())
- {
- reportAlways("StatDb: no stats found");
- addDefaultStats();
- }
- }
-}
-
-void StatDb::unload()
-{
- logger->log1("Unloading stat database...");
-
- mBasicStats.clear();
- mStats.clear();
- mPages.clear();
- mLoaded = false;
-}
diff --git a/src/resources/db/statdb.h b/src/resources/db/statdb.h
deleted file mode 100644
index 73b24894b..000000000
--- a/src/resources/db/statdb.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_STATDB_H
-#define RESOURCES_DB_STATDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include "resources/basicstat.h"
-
-#include "localconsts.h"
-
-namespace StatDb
-{
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void addDefaultStats();
-
- const STD_VECTOR<BasicStat> &getBasicStats();
-
- const STD_VECTOR<BasicStat> &getStats(const std::string &page);
-
- const STD_VECTOR<std::string> &getPages();
-} // namespace StatDb
-
-#endif // RESOURCES_DB_STATDB_H
diff --git a/src/resources/db/statuseffectdb.cpp b/src/resources/db/statuseffectdb.cpp
deleted file mode 100644
index b02c666d6..000000000
--- a/src/resources/db/statuseffectdb.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/statuseffectdb.h"
-
-#include "configuration.h"
-#include "settings.h"
-#include "statuseffect.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- typedef std::map<int, StatusEffect *> IdToEffectMap[2];
- bool mLoaded = false;
- int fakeId = 10000;
- IdToEffectMap statusEffects;
- OptionsMap optionToIdMap;
- OptionsMap opt1ToIdMap;
- OptionsMap opt2ToIdMap;
- OptionsMap opt3ToIdMap;
-
- OptionsMap blockIdToIdMap;
-} // namespace
-
-int StatusEffectDB::blockIdToId(const int blockIndex)
-{
- if (blockIdToIdMap.find(blockIndex) == blockIdToIdMap.end())
- return -1;
- return blockIdToIdMap[blockIndex];
-}
-
-StatusEffect *StatusEffectDB::getStatusEffect(const int index,
- const Enable enabling)
-{
- std::map<int, StatusEffect *> &effects
- = statusEffects[enabling == Enable_true];
- const std::map<int, StatusEffect *>::iterator it = effects.find(index);
- if (it != effects.end())
- return (*it).second;
- reportAlways("Missing status effect: %d",
- index);
- return nullptr;
-}
-
-void StatusEffectDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing status effect database...");
-
- loadXmlFile(paths.getStringValue("statusEffectsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("statusEffectsPatchFile"),
- SkipError_true);
- loadXmlDir("statusEffectsPatchDir", loadXmlFile);
-
- if (!blockIdToIdMap.empty())
- {
- reportAlways("Detected legacy attribute block-id "
- "in status-effects.xml");
- }
- mLoaded = true;
-}
-
-void StatusEffectDB::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "status-effects"))
- {
- logger->log("Error loading status effects file: " + fileName);
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string incName = XML::getProperty(node, "name", "");
- if (!incName.empty())
- loadXmlFile(incName, skipError);
- continue;
- }
- else if (!xmlNameEqual(node, "status-effect"))
- {
- continue;
- }
-
- int id = XML::getProperty(node, "id", -1);
-
- // legacy field. Only for clients 1.6.3.12 and older
- const int blockId = XML::getProperty(node, "block-id", -1);
- if (id >= 0 && blockId >= 0)
- blockIdToIdMap[blockId] = id;
-
- if (id == -1)
- {
- id = fakeId;
- fakeId ++;
- }
- const int option = XML::getProperty(node, "option", 0);
- const int opt1 = XML::getProperty(node, "opt1", 0);
- const int opt2 = XML::getProperty(node, "opt2", 0);
- const int opt3 = XML::getProperty(node, "opt3", 0);
- if (option != 0)
- {
- optionToIdMap[option] = id;
- settings.legacyEffects = false;
- }
- if (opt1 != 0)
- {
- opt1ToIdMap[opt1] = id;
- settings.legacyEffects = false;
- }
- if (opt2 != 0)
- {
- opt2ToIdMap[opt2] = id;
- settings.legacyEffects = false;
- }
- if (opt3 != 0)
- {
- opt3ToIdMap[opt3] = id;
- settings.legacyEffects = false;
- }
-
- StatusEffect *startEffect = statusEffects[1][id];
- StatusEffect *endEffect = statusEffects[0][id];
- const std::string name = XML::getProperty(node, "name", "");
- const std::string name2 = XML::langProperty(node, "name", "");
- if (startEffect == nullptr)
- startEffect = new StatusEffect;
- if (endEffect == nullptr)
- endEffect = new StatusEffect;
-
- startEffect->mName = name2;
- startEffect->mIsPoison =
- (name == paths.getStringValue("poisonEffectName"));
- startEffect->mIsCart =
- (name == paths.getStringValue("cartEffectName"));
- startEffect->mIsRiding =
- (name == paths.getStringValue("ridingEffectName"));
- startEffect->mIsTrickDead =
- (name == paths.getStringValue("trickDeadEffectName"));
- startEffect->mIsPostDelay =
- (name == paths.getStringValue("postDelayName"));
- startEffect->mMessage = XML::getProperty(
- node, "start-message", "");
- startEffect->mSFXEffect = XML::getProperty(
- node, "start-audio", "");
- startEffect->mStartParticleEffect = XML::getProperty(
- node, "start-particle", "");
- startEffect->mParticleEffect = XML::getProperty(
- node, "particle", "");
-
- startEffect->mIcon = XML::getProperty(node, "icon", "");
- startEffect->mAction = XML::getProperty(node, "action", "");
- startEffect->mIsPersistent = (XML::getProperty(
- node, "persistent-particle-effect", "no")) != "no";
-
- endEffect->mName = startEffect->mName;
- endEffect->mIsPoison = startEffect->mIsPoison;
- endEffect->mIsCart = startEffect->mIsCart;
- endEffect->mIsRiding = startEffect->mIsRiding;
- endEffect->mIsTrickDead = startEffect->mIsTrickDead;
- endEffect->mIsPostDelay = startEffect->mIsPostDelay;
- endEffect->mMessage = XML::getProperty(node, "end-message", "");
- endEffect->mSFXEffect = XML::getProperty(node, "end-audio", "");
- endEffect->mStartParticleEffect = XML::getProperty(
- node, "end-particle", "");
-
- statusEffects[1][id] = startEffect;
- statusEffects[0][id] = endEffect;
- }
-}
-
-static void unloadMap(std::map<int, StatusEffect *> &map)
-{
- for (std::map<int, StatusEffect *>::iterator it = map.begin();
- it != map.end(); ++it)
- {
- delete (*it).second;
- }
-
- map.clear();
-}
-
-void StatusEffectDB::unload()
-{
- if (!mLoaded)
- return;
-
- logger->log1("Unloading status effect database...");
-
- fakeId = 10000;
- unloadMap(statusEffects[0]);
- unloadMap(statusEffects[1]);
-
- optionToIdMap.clear();
- opt1ToIdMap.clear();
- opt2ToIdMap.clear();
- opt3ToIdMap.clear();
- blockIdToIdMap.clear();
-
- mLoaded = false;
-}
-
-const OptionsMap& StatusEffectDB::getOptionMap()
-{
- return optionToIdMap;
-}
-
-const OptionsMap& StatusEffectDB::getOpt1Map()
-{
- return opt1ToIdMap;
-}
-
-const OptionsMap& StatusEffectDB::getOpt2Map()
-{
- return opt2ToIdMap;
-}
-
-const OptionsMap& StatusEffectDB::getOpt3Map()
-{
- return opt3ToIdMap;
-}
diff --git a/src/resources/db/statuseffectdb.h b/src/resources/db/statuseffectdb.h
deleted file mode 100644
index 39af1f0e7..000000000
--- a/src/resources/db/statuseffectdb.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_STATUSEFFECTDB_H
-#define RESOURCES_DB_STATUSEFFECTDB_H
-
-#include "enums/simpletypes/enable.h"
-#include "enums/simpletypes/skiperror.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-class StatusEffect;
-
-typedef std::map<uint32_t, uint32_t> OptionsMap;
-typedef OptionsMap::const_iterator OptionsMapCIter;
-
-namespace StatusEffectDB
-{
- /**
- * Retrieves a status effect.
- *
- * \param index Index of the status effect.
- * \param enabling Whether to retrieve the activating effect (true) or
- * the deactivating effect (false).
- */
- StatusEffect *getStatusEffect(const int index,
- const Enable enabling) A_WARN_UNUSED;
-
- /**
- * Maps a block effect index to its corresponding effect index. Block
- * effect indices are used for opt2/opt3/status.option blocks; their
- * mapping to regular effect indices is handled in the config file.
- *
- * Returns -1 on failure.
- */
- int blockIdToId(const int blocKIndex) A_WARN_UNUSED;
-
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void unload();
-
- const OptionsMap& getOptionMap();
-
- const OptionsMap& getOpt1Map();
-
- const OptionsMap& getOpt2Map();
-
- const OptionsMap& getOpt3Map();
-} // namespace StatusEffectDB
-
-#endif // RESOURCES_DB_STATUSEFFECTDB_H
diff --git a/src/resources/db/textdb.cpp b/src/resources/db/textdb.cpp
deleted file mode 100644
index cfd5faf76..000000000
--- a/src/resources/db/textdb.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/textdb.h"
-
-#include "configuration.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-namespace
-{
- StringVect mTexts;
-} // namespace
-
-void TextDb::load()
-{
- unload();
- logger->log1("Initializing text database...");
- loadXmlFile(paths.getStringValue("textsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("textsPatchFile"), SkipError_true);
- loadXmlDir("textsPatchDir", loadXmlFile);
-}
-
-void TextDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "texts"))
- {
- delete doc;
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "text"))
- {
- const bool show = XML::getBoolProperty(node, "show", false);
- if (show == true)
- {
- if (!XmlHaveChildContent(node))
- continue;
-
- std::string text = XmlChildContent(node);
- mTexts.push_back(text);
- }
- }
- }
-
- delete doc;
-}
-
-void TextDb::unload()
-{
- logger->log1("Unloading text database...");
- mTexts.clear();
-}
-
-const StringVect &TextDb::getTexts()
-{
- return mTexts;
-}
-
-std::string TextDb::getByIndex(const int index)
-{
- if (index < 0 ||
- static_cast<size_t>(index) >= mTexts.size())
- {
- return std::string();
- }
- return mTexts[index];
-}
diff --git a/src/resources/db/textdb.h b/src/resources/db/textdb.h
deleted file mode 100644
index 2eb438336..000000000
--- a/src/resources/db/textdb.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_TEXTDB_H
-#define RESOURCES_DB_TEXTDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-namespace TextDb
-{
- void load();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- std::string getByIndex(const int index);
-
- const StringVect &getTexts();
-
- void unload();
-} // namespace TextDb
-
-#endif // RESOURCES_DB_TEXTDB_H
diff --git a/src/resources/db/unitsdb.cpp b/src/resources/db/unitsdb.cpp
deleted file mode 100644
index a32786b84..000000000
--- a/src/resources/db/unitsdb.cpp
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/unitsdb.h"
-
-#include "configuration.h"
-
-#include "const/resources/currency.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/stdmove.h"
-
-#include "resources/beingcommon.h"
-
-#include <climits>
-
-#include "debug.h"
-
-namespace
-{
- struct UnitLevel final
- {
- A_DEFAULT_COPY(UnitLevel)
-
- std::string symbol;
- int count;
- int round;
- std::string separator;
- };
-
- struct UnitDescription final
- {
- A_DEFAULT_COPY(UnitDescription)
-
- STD_VECTOR<struct UnitLevel> levels;
- double conversion;
- bool mix;
- };
-
- UnitDescription defaultCurrency;
- UnitDescription defaultWeight;
-
- std::map<std::string, UnitDescription> mCurrencies;
-} // namespace
-
-static std::string formatUnit(const int value,
- const UnitDescription &ud);
-
-static std::string splitNumber(std::string str,
- const std::string &separator);
-
-void UnitsDb::load()
-{
- logger->log1("Initializing unit database...");
- { // Setup default weight
- UnitDescription ud;
-
- ud.conversion = 1.0;
- ud.mix = false;
-
- const UnitLevel bu =
- {
- "g",
- 1,
- 0,
- ""
- };
- ud.levels.push_back(bu);
-
- const UnitLevel ul =
- {
- "kg",
- 1000,
- 2,
- ""
- };
- ud.levels.push_back(ul);
-
- defaultWeight = ud;
- }
-
- { // Setup default currency
- UnitDescription ud;
-
- ud.conversion = 1.0;
- ud.mix = false;
-
- const UnitLevel bu = {"¤", 1, 0, ""};
- ud.levels.push_back(bu);
-
- defaultCurrency = ud;
- }
-
- loadXmlFile(paths.getStringValue("unitsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("unitsPatchFile"), SkipError_true);
- loadXmlDir("unitsPatchDir", loadXmlFile);
-}
-
-void UnitsDb::unload()
-{
- logger->log1("Unloading unit database...");
- mCurrencies.clear();
-}
-
-static UnitDescription loadUnit(XmlNodePtr node)
-{
- UnitDescription ud;
- int level = 1;
- ud.conversion = XML::getProperty(node, "conversion", 1);
- ud.mix = XML::getProperty(node, "mix", "no") == "yes";
-
- UnitLevel bu;
- bu.symbol = XML::getProperty(node, "base", "¤");
- bu.count = 1;
- bu.round = XML::getProperty(node, "round", 2);
- bu.separator = XML::getProperty(node, "separator", " ");
-
- ud.levels.push_back(bu);
-
- for_each_xml_child_node(uLevel, node)
- {
- if (xmlNameEqual(uLevel, "level"))
- {
- const UnitLevel ul =
- {
- XML::getProperty(uLevel, "symbol",
- strprintf("¤%d", level)),
- XML::getProperty(uLevel, "count", -1),
- XML::getProperty(uLevel, "round", bu.round),
- XML::getProperty(uLevel, "separator", bu.separator)
- };
-
- if (ul.count > 0)
- {
- ud.levels.push_back(ul);
- level++;
- }
- else
- {
- logger->log("Error bad unit count: %d for %s in %s",
- ul.count,
- ul.symbol.c_str(),
- bu.symbol.c_str());
- }
- }
- }
-
- // Add one more level for saftey
- const UnitLevel lev =
- {
- "",
- INT_MAX,
- 0,
- ""
- };
- ud.levels.push_back(lev);
- return ud;
-}
-
-static void loadCurrencies(XmlNodePtr parentNode)
-{
- for_each_xml_child_node(node, parentNode)
- {
- if (xmlNameEqual(node, "unit"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (name.empty())
- {
- reportAlways("Error: unknown currency name.");
- continue;
- }
- mCurrencies[name] = loadUnit(node);
- if (name == DEFAULT_CURRENCY)
- defaultCurrency = mCurrencies[name];
- }
- }
-}
-
-void UnitsDb::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst root = doc.rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "units"))
- {
- logger->log("Error loading unit definition file: "
- + paths.getStringValue("unitsFile"));
- return;
- }
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string name = XML::getProperty(node, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(node, "unit"))
- {
- const std::string type = XML::getProperty(node, "type", "");
- UnitDescription ud = loadUnit(node);
- if (type == "weight")
- {
- defaultWeight = ud;
- }
- else if (type == "currency")
- {
- defaultCurrency = ud;
- mCurrencies[DEFAULT_CURRENCY] = ud;
- }
- else
- {
- logger->log("Error unknown unit type: %s", type.c_str());
- }
- }
- else if (xmlNameEqual(node, "currency"))
- {
- loadCurrencies(node);
- }
- }
-}
-
-static std::string formatUnit(const int value,
- const UnitDescription &ud)
-{
- UnitLevel ul;
-
- // Shortcut for 0; do the same for values less than 0 (for now)
- if (value <= 0)
- {
- ul = ud.levels[0];
- return strprintf("0%s", ul.symbol.c_str());
- }
-
- double amount = ud.conversion * value;
- const unsigned int sz = CAST_U32(ud.levels.size());
-
- // If only the first level is needed, act like mix if false
- if (ud.mix && !ud.levels.empty() && ud.levels[1].count < amount)
- {
- std::string output;
- UnitLevel pl = ud.levels[0];
- ul = ud.levels[1];
- int levelAmount = CAST_S32(amount);
- int nextAmount = 0;
-
- if (ul.count != 0)
- levelAmount /= ul.count;
-
- amount -= static_cast<double>(levelAmount * ul.count);
-
- if (amount > 0)
- {
- output = splitNumber(strprintf("%.*f", pl.round,
- amount), pl.separator).append(pl.symbol);
- }
-
- for (unsigned int i = 2; i < sz; i++)
- {
- pl = ul;
- ul = ud.levels[i];
-
- if (ul.count != 0)
- {
- nextAmount = levelAmount / ul.count;
- levelAmount %= ul.count;
- }
-
- if (levelAmount > 0)
- {
- output = splitNumber(strprintf("%d", levelAmount),
- pl.separator).append(pl.symbol).append(output);
- }
-
- if (nextAmount == 0)
- break;
- levelAmount = nextAmount;
- }
-
- return output;
- }
-
- ul.round = 0;
- for (unsigned int i = 0; i < sz; i++)
- {
- ul = ud.levels[i];
- if (amount < ul.count && ul.count > 0)
- {
- ul = ud.levels[i - 1];
- break;
- }
- if (ul.count != 0)
- amount /= ul.count;
- }
-
- return splitNumber(strprintf("%.*f", ul.round, amount),
- ul.separator).append(ul.symbol);
-}
-
-std::string UnitsDb::formatCurrency(const int value)
-{
- return formatUnit(value, defaultCurrency);
-}
-
-std::string UnitsDb::formatCurrency64(const int64_t value)
-{
- return formatUnit(CAST_S32(value),
- defaultCurrency);
-}
-
-std::string UnitsDb::formatCurrency(std::string name,
- const int value)
-{
- if (mCurrencies.find(name) == mCurrencies.end())
- name = DEFAULT_CURRENCY;
- return formatUnit(value, mCurrencies[name]);
-}
-
-std::string UnitsDb::formatCurrency64(std::string name,
- const int64_t value)
-{
- if (mCurrencies.find(name) == mCurrencies.end())
- name = DEFAULT_CURRENCY;
- return formatUnit(CAST_S32(value),
- mCurrencies[name]);
-}
-
-std::string UnitsDb::formatWeight(const int value)
-{
- return formatUnit(value, defaultWeight);
-}
-
-bool UnitsDb::existsCurrency(const std::string &name)
-{
- return mCurrencies.find(name) != mCurrencies.end();
-}
-
-static std::string splitNumber(std::string str,
- const std::string &separator)
-{
- std::string lastPart;
- const size_t point = str.find('.');
- if (point != std::string::npos)
- {
- lastPart = str.substr(point);
- str = str.substr(0, point);
- }
- std::string result;
-
- if (!str.empty())
- {
- size_t sz = str.size();
- while (sz >= 3)
- {
- if (sz >= 6)
- {
- result = std::string(separator).append(str.substr(
- sz - 3)).append(result);
- }
- else
- {
- result = str.substr(sz - 3).append(result);
- }
- str = str.substr(0, str.size() - 3);
- sz = str.size();
- }
- if (!str.empty())
- {
- if (!result.empty())
- result = std::string(str).append(separator).append(result);
- else
- result = STD_MOVE(str);
- }
- }
-
- return result + lastPart;
-}
diff --git a/src/resources/db/unitsdb.h b/src/resources/db/unitsdb.h
deleted file mode 100644
index 859adaabc..000000000
--- a/src/resources/db/unitsdb.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_UNITSDB_H
-#define RESOURCES_DB_UNITSDB_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace UnitsDb
-{
- /**
- * Loads and parses the units.xml file (if found).
- */
- void load();
-
- void unload();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Formats the given number in the correct currency format.
- */
- std::string formatCurrency(const int value) A_WARN_UNUSED;
-
- std::string formatCurrency64(const int64_t value) A_WARN_UNUSED;
-
- /**
- * Formats the given number in the correct currency format.
- */
- std::string formatCurrency(std::string name,
- const int value) A_WARN_UNUSED;
-
- std::string formatCurrency64(std::string name,
- const int64_t value) A_WARN_UNUSED;
-
- /**
- * Formats the given number in the correct weight/mass format.
- */
- std::string formatWeight(const int value) A_WARN_UNUSED;
-
- bool existsCurrency(const std::string &name) A_WARN_UNUSED;
-} // namespace UnitsDb
-
-#endif // RESOURCES_DB_UNITSDB_H
diff --git a/src/resources/db/weaponsdb.cpp b/src/resources/db/weaponsdb.cpp
deleted file mode 100644
index f23a0dfc3..000000000
--- a/src/resources/db/weaponsdb.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/db/weaponsdb.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/xmlutils.h"
-
-#include "debug.h"
-
-namespace
-{
- WeaponsInfos mBows;
- WeaponsInfos mSwords;
- WeaponsInfos mShields;
- bool mLoaded = false;
-} // namespace
-
-static void loadDB(const std::string &name,
- WeaponsInfos &arr)
-{
- readXmlIntVector(paths.getStringValue("weaponsFile"),
- "weapons",
- name,
- "item",
- "id",
- arr,
- SkipError_false);
-}
-
-void WeaponsDB::load()
-{
- if (mLoaded)
- unload();
-
- logger->log1("Initializing weapon database...");
-
- loadDB("swords", mSwords);
- loadDB("bows", mBows);
- loadDB("shields", mShields);
-}
-
-void WeaponsDB::unload()
-{
- logger->log1("Unloading weapon database...");
-
- mBows.clear();
- mSwords.clear();
- mShields.clear();
- mLoaded = false;
-}
-
-const WeaponsInfos &WeaponsDB::getBows()
-{
- return mBows;
-}
-
-const WeaponsInfos &WeaponsDB::getSwords()
-{
- return mSwords;
-}
-
-const WeaponsInfos &WeaponsDB::getShields()
-{
- return mShields;
-}
diff --git a/src/resources/db/weaponsdb.h b/src/resources/db/weaponsdb.h
deleted file mode 100644
index a957347bc..000000000
--- a/src/resources/db/weaponsdb.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DB_WEAPONSDB_H
-#define RESOURCES_DB_WEAPONSDB_H
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-typedef STD_VECTOR<int> WeaponsInfos;
-typedef WeaponsInfos::const_iterator WeaponsInfosIter;
-
-namespace WeaponsDB
-{
- void load();
-
- void unload();
-
- const WeaponsInfos &getBows();
-
- const WeaponsInfos &getSwords();
-
- const WeaponsInfos &getShields();
-} // namespace WeaponsDB
-
-#endif // RESOURCES_DB_WEAPONSDB_H
diff --git a/src/resources/dbmanager.cpp b/src/resources/dbmanager.cpp
deleted file mode 100644
index 6a0ee16d7..000000000
--- a/src/resources/dbmanager.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/dbmanager.h"
-
-#include "being/being.h"
-
-#include "net/loginhandler.h"
-#include "net/net.h"
-
-#include "resources/db/avatardb.h"
-#include "resources/db/badgesdb.h"
-#include "resources/db/chardb.h"
-#include "resources/db/colordb.h"
-#include "resources/db/deaddb.h"
-#include "resources/db/elementaldb.h"
-#include "resources/db/emotedb.h"
-#include "resources/db/groupdb.h"
-#include "resources/db/homunculusdb.h"
-#include "resources/db/horsedb.h"
-#include "resources/db/itemdb.h"
-#include "resources/db/itemfielddb.h"
-#include "resources/db/itemoptiondb.h"
-#include "resources/db/languagedb.h"
-#include "resources/db/sounddb.h"
-#include "resources/db/mapdb.h"
-#include "resources/db/mercenarydb.h"
-#include "resources/db/moddb.h"
-#include "resources/db/monsterdb.h"
-#include "resources/db/networkdb.h"
-#include "resources/db/npcdb.h"
-#include "resources/db/npcdialogdb.h"
-#include "resources/db/palettedb.h"
-#include "resources/db/petdb.h"
-#include "resources/db/skillunitdb.h"
-#include "resources/db/statdb.h"
-#include "resources/db/statuseffectdb.h"
-#include "resources/db/textdb.h"
-#include "resources/db/unitsdb.h"
-#include "resources/db/weaponsdb.h"
-
-#include "debug.h"
-
-void DbManager::loadDb()
-{
- CharDB::load();
- GroupDb::load();
- StatDb::load();
- DeadDB::load();
- PaletteDB::load();
- ColorDB::load();
- SoundDB::load();
- LanguageDb::load();
- TextDb::load();
- MapDB::load();
- ItemFieldDb::load();
- ItemOptionDb::load();
- ItemDB::load();
- Being::load();
- const ServerTypeT type = Net::getNetworkType();
- if (type == ServerType::EATHENA ||
- type == ServerType::EVOL2)
- {
- NetworkDb::load();
- if (loginHandler != nullptr)
- loginHandler->updatePacketVersion();
- MercenaryDB::load();
- HomunculusDB::load();
- ElementalDb::load();
- SkillUnitDb::load();
- HorseDB::load();
- }
- MonsterDB::load();
- AvatarDB::load();
- BadgesDB::load();
- WeaponsDB::load();
- UnitsDb::load();
- NPCDB::load();
- NpcDialogDB::load();
- PETDB::load();
- EmoteDB::load();
-// ModDB::load();
- StatusEffectDB::load();
-}
-
-void DbManager::unloadDb()
-{
- CharDB::unload();
- GroupDb::unload();
- StatDb::unload();
- DeadDB::unload();
- ColorDB::unload();
- SoundDB::unload();
- LanguageDb::unload();
- TextDb::unload();
- EmoteDB::unload();
- ItemDB::unload();
- ItemOptionDb::unload();
- ItemFieldDb::unload();
- const ServerTypeT type = Net::getNetworkType();
- if (type == ServerType::EATHENA ||
- type == ServerType::EVOL2)
- {
- MercenaryDB::unload();
- HomunculusDB::unload();
- ElementalDb::unload();
- SkillUnitDb::unload();
- HorseDB::unload();
- NetworkDb::unload();
- }
- MonsterDB::unload();
- NPCDB::unload();
- NpcDialogDB::unload();
- AvatarDB::unload();
- BadgesDB::unload();
- WeaponsDB::unload();
- UnitsDb::unload();
- PaletteDB::unload();
- PETDB::unload();
- StatusEffectDB::unload();
- ModDB::unload();
-}
diff --git a/src/resources/dbmanager.h b/src/resources/dbmanager.h
deleted file mode 100644
index deaddf47d..000000000
--- a/src/resources/dbmanager.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DBMANAGER_H
-#define RESOURCES_DBMANAGER_H
-
-namespace DbManager
-{
- void loadDb();
- void unloadDb();
-} // namespace DbManager
-
-#endif // RESOURCES_DBMANAGER_H
diff --git a/src/resources/delayedmanager.cpp b/src/resources/delayedmanager.cpp
deleted file mode 100644
index 1296095bb..000000000
--- a/src/resources/delayedmanager.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/delayedmanager.h"
-
-#include "resources/sprite/animationdelayload.h"
-
-#include "utils/foreach.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-DelayedAnim DelayedManager::mDelayedAnimations;
-
-void DelayedManager::delayedLoad()
-{
- BLOCK_START("DelayedManager::delayedLoad")
- static int loadTime = 0;
- if (loadTime < cur_time)
- {
- loadTime = tick_time;
-
- int k = 0;
- DelayedAnimIter it = mDelayedAnimations.begin();
- const DelayedAnimIter it_end = mDelayedAnimations.end();
- while (it != it_end && k < 1)
- {
- (*it)->load();
- AnimationDelayLoad *tmp = *it;
- it = mDelayedAnimations.erase(it);
- delete tmp;
- k ++;
- }
- const int time2 = tick_time;
- if (time2 > loadTime)
- loadTime = time2 + (time2 - loadTime) * 2 + 10;
- else
- loadTime = time2 + 3;
- }
- BLOCK_END("DelayedManager::delayedLoad")
-}
-
-void DelayedManager::removeDelayLoad(const AnimationDelayLoad
- *const delayedLoad)
-{
- FOR_EACH (DelayedAnimIter, it, mDelayedAnimations)
- {
- if (*it == delayedLoad)
- {
- mDelayedAnimations.erase(it);
- return;
- }
- }
-}
diff --git a/src/resources/delayedmanager.h b/src/resources/delayedmanager.h
deleted file mode 100644
index 085efbbdf..000000000
--- a/src/resources/delayedmanager.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DELAYEDMANAGER_H
-#define RESOURCES_DELAYEDMANAGER_H
-
-#include <list>
-
-#include "localconsts.h"
-
-class AnimationDelayLoad;
-
-typedef std::list<AnimationDelayLoad*> DelayedAnim;
-typedef DelayedAnim::iterator DelayedAnimIter;
-
-/**
- * A class for loading and managing resources.
- */
-class DelayedManager final
-{
- public:
- DelayedManager()
- { }
-
- A_DELETE_COPY(DelayedManager)
-
- static void addDelayedAnimation(AnimationDelayLoad *const animation)
- { mDelayedAnimations.push_back(animation); }
-
- static void delayedLoad();
-
- static void removeDelayLoad(const AnimationDelayLoad
- *const delayedLoad);
-
-
- private:
- static DelayedAnim mDelayedAnimations;
-};
-
-#endif // RESOURCES_DELAYEDMANAGER_H
diff --git a/src/resources/dye/dye.cpp b/src/resources/dye/dye.cpp
deleted file mode 100644
index 65755bb87..000000000
--- a/src/resources/dye/dye.cpp
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/dye/dye.h"
-
-#include "logger.h"
-
-#include "resources/dye/dyepalette.h"
-
-#include "utils/delete2.h"
-
-#include <sstream>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-Dye::Dye(const std::string &restrict description)
-{
- for (int i = 0; i < dyePalateSize; ++i)
- mDyePalettes[i] = nullptr;
-
- if (description.empty())
- return;
-
- size_t next_pos = 0;
- const size_t length = description.length();
- do
- {
- const size_t pos = next_pos;
- next_pos = description.find(';', pos);
-
- if (next_pos == std::string::npos)
- next_pos = length;
-
- if (next_pos <= pos + 3 || description[pos + 1] != ':')
- {
- logger->log("Error, invalid dye: %s", description.c_str());
- return;
- }
-
- int i = 0;
-
- switch (description[pos])
- {
- case 'R': i = 0; break;
- case 'G': i = 1; break;
- case 'Y': i = 2; break;
- case 'B': i = 3; break;
- case 'M': i = 4; break;
- case 'C': i = 5; break;
- case 'W': i = 6; break;
- case 'S': i = 7; break;
- case 'A': i = 8; break;
- default:
- logger->log("Error, invalid dye: %s", description.c_str());
- return;
- }
- mDyePalettes[i] = new DyePalette(description.substr(
- pos + 2, next_pos - pos - 2), i != 8 ? 6 : 8);
- ++next_pos;
- }
- while (next_pos < length);
-}
-
-Dye::~Dye()
-{
- for (int i = 0; i < dyePalateSize; ++i)
- delete2(mDyePalettes[i])
-}
-
-void Dye::instantiate(std::string &restrict target,
- const std::string &restrict palettes)
-{
- size_t next_pos = target.find('|');
-
- if (next_pos == std::string::npos || palettes.empty())
- return;
-
- ++next_pos;
-
- std::ostringstream s;
- s << target.substr(0, next_pos);
- size_t last_pos = target.length(), pal_pos = 0;
- do
- {
- const size_t pos = next_pos;
- next_pos = target.find(';', pos);
-
- if (next_pos == std::string::npos)
- next_pos = last_pos;
-
- if (next_pos == pos + 1 && pal_pos != std::string::npos)
- {
- const size_t pal_next_pos = palettes.find(';', pal_pos);
- s << target[pos] << ':';
- if (pal_next_pos == std::string::npos)
- {
- s << palettes.substr(pal_pos);
- s << target.substr(next_pos);
- break;
- }
- s << palettes.substr(pal_pos, pal_next_pos - pal_pos);
- pal_pos = pal_next_pos + 1;
- }
- else if (next_pos > pos + 2)
- {
- s << target.substr(pos, next_pos - pos);
- }
- else
- {
- logger->log("Error, invalid dye placeholder: %s", target.c_str());
- return;
- }
- s << target[next_pos];
- ++next_pos;
- }
- while (next_pos < last_pos);
-
- target = s.str();
-}
-
-int Dye::getType() const restrict2 noexcept2
-{
- if (mDyePalettes[sPaleteIndex] != nullptr)
- return 1;
- if (mDyePalettes[aPaleteIndex] != nullptr)
- return 2;
- return 0;
-}
-
-void Dye::normalDye(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- if (pixels == nullptr)
- return;
-
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- const uint32_t p = pixels[ptr];
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int alpha = p & 0xff000000;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int alpha = p & 0xff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (alpha)
- {
- unsigned int color[3];
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- color[0] = (p) & 255U;
- color[1] = (p >> 8U) & 255U;
- color[2] = (p >> 16U) & 255U;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- color[0] = (p >> 24U) & 255U;
- color[1] = (p >> 16U) & 255U;
- color[2] = (p >> 8U) & 255U;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int cmax = std::max(
- color[0], std::max(color[1], color[2]));
- if (cmax == 0)
- goto endlabel;
-
- const unsigned int cmin = std::min(
- color[0], std::min(color[1], color[2]));
- const unsigned int intensity = color[0] + color[1] + color[2];
- unsigned int i;
-
- if (cmin != cmax && (cmin != 0 || (intensity != cmax
- && intensity != 2 * cmax)))
- {
- // not pure
- goto endlabel;
- }
-
- i = (color[0] != 0) | ((color[1] != 0) << 1)
- | ((color[2] != 0) << 2);
-
- if (mDyePalettes[i - 1])
- mDyePalettes[i - 1]->getColor(cmax, color);
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- pixels[ptr] = (color[0]) | (color[1] << 8)
- | (color[2] << 16) | alpha;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- pixels[ptr] = (color[0] << 24) | (color[1] << 16)
- | (color[2] << 8) | alpha;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
-endlabel:{}
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++ pixels)
- {
- const uint32_t p = *pixels;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int alpha = p & 0xff000000;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int alpha = p & 0xff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (alpha == 0)
- continue;
- unsigned int color[3];
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- color[0] = (p) & 255U;
- color[1] = (p >> 8U) & 255U;
- color[2] = (p >> 16U) & 255U;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- color[0] = (p >> 24U) & 255U;
- color[1] = (p >> 16U) & 255U;
- color[2] = (p >> 8U) & 255U;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int cmax = std::max(
- color[0], std::max(color[1], color[2]));
- if (cmax == 0)
- continue;
-
- const unsigned int cmin = std::min(
- color[0], std::min(color[1], color[2]));
- const unsigned int intensity = color[0] + color[1] + color[2];
-
- if (cmin != cmax && (cmin != 0 || (intensity != cmax
- && intensity != 2 * cmax)))
- {
- // not pure
- continue;
- }
-
- const unsigned int i = static_cast<int>(color[0] != 0) |
- (static_cast<int>(color[1] != 0) << 1) |
- (static_cast<int>(color[2] != 0) << 2);
-
- if (mDyePalettes[i - 1] != nullptr)
- mDyePalettes[i - 1]->getColor(cmax, color);
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- *pixels = (color[0]) | (color[1] << 8)
- | (color[2] << 16) | alpha;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- *pixels = (color[0] << 24) | (color[1] << 16)
- | (color[2] << 8) | alpha;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
-#endif // ENABLE_CILKPLUS
-}
-
-void Dye::normalOGLDye(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- if (pixels == nullptr)
- return;
-
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- const uint32_t p = pixels[ptr];
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int alpha = p & 255;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int alpha = p & 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (alpha)
- {
- unsigned int color[3];
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- color[0] = (p >> 24U) & 255U;
- color[1] = (p >> 16U) & 255U;
- color[2] = (p >> 8U) & 255U;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- color[0] = (p) & 255U;
- color[1] = (p >> 8U) & 255U;
- color[2] = (p >> 16U) & 255U;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int cmax = std::max(
- color[0], std::max(color[1], color[2]));
- if (cmax == 0)
- goto endlabel;
-
- const unsigned int cmin = std::min(
- color[0], std::min(color[1], color[2]));
- const unsigned int intensity = color[0] + color[1] + color[2];
-
- if (cmin != cmax && (cmin != 0 || (intensity != cmax
- && intensity != 2 * cmax)))
- {
- // not pure
- goto endlabel;
- }
-
- const unsigned int i = (color[0] != 0) | ((color[1] != 0) << 1)
- | ((color[2] != 0) << 2);
-
- if (mDyePalettes[i - 1])
- mDyePalettes[i - 1]->getColor(cmax, color);
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- pixels[ptr] = (color[0] << 24) | (color[1] << 16)
- | (color[2] << 8) | alpha;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- pixels[ptr] = (color[0]) | (color[1] << 8)
- | (color[2] << 16) | alpha;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
-endlabel:{}
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++ pixels)
- {
- const uint32_t p = *pixels;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int alpha = p & 255;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int alpha = p & 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (alpha == 0)
- continue;
- unsigned int color[3];
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- color[0] = (p >> 24U) & 255U;
- color[1] = (p >> 16U) & 255U;
- color[2] = (p >> 8U) & 255U;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- color[0] = (p) & 255U;
- color[1] = (p >> 8U) & 255U;
- color[2] = (p >> 16U) & 255U;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int cmax = std::max(
- color[0], std::max(color[1], color[2]));
- if (cmax == 0)
- continue;
-
- const unsigned int cmin = std::min(
- color[0], std::min(color[1], color[2]));
- const unsigned int intensity = color[0] + color[1] + color[2];
-
- if (cmin != cmax && (cmin != 0 || (intensity != cmax
- && intensity != 2 * cmax)))
- {
- // not pure
- continue;
- }
-
- const unsigned int i = static_cast<int>(color[0] != 0) |
- (static_cast<int>(color[1] != 0) << 1) |
- (static_cast<int>(color[2] != 0) << 2);
-
- if (mDyePalettes[i - 1] != nullptr)
- mDyePalettes[i - 1]->getColor(cmax, color);
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- *pixels = (color[0] << 24) | (color[1] << 16)
- | (color[2] << 8) | alpha;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- *pixels = (color[0]) | (color[1] << 8)
- | (color[2] << 16) | alpha;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
-#endif // ENABLE_CILKPLUS
-}
diff --git a/src/resources/dye/dye.h b/src/resources/dye/dye.h
deleted file mode 100644
index 1f8eb2fdd..000000000
--- a/src/resources/dye/dye.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DYE_DYE_H
-#define RESOURCES_DYE_DYE_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class DyePalette;
-
-const int dyePalateSize = 9;
-const int sPaleteIndex = 7;
-const int aPaleteIndex = 8;
-
-/**
- * Class for dispatching pixel-recoloring amongst several palettes.
- */
-class Dye final
-{
- public:
- /**
- * Creates a set of palettes based on the given string.
- *
- * The parts of string are separated by semi-colons. Each part starts
- * by an uppercase letter, followed by a colon and then a palette name.
- */
- explicit Dye(const std::string &restrict dye);
-
- A_DELETE_COPY(Dye)
-
- /**
- * Destroys the associated palettes.
- */
- ~Dye();
-
- /**
- * Fills the blank in a dye placeholder with some palette names.
- */
- static void instantiate(std::string &restrict target,
- const std::string &restrict palettes);
-
- /**
- * Return special dye palete (S)
- */
- const DyePalette *getSPalete() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDyePalettes[sPaleteIndex]; }
-
- /**
- * Return special dye palete (A)
- */
- const DyePalette *getAPalete() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDyePalettes[aPaleteIndex]; }
-
- /**
- * Return dye type for S - 1, for A - 2, 0 for other
- */
- int getType() const restrict2 noexcept2 A_WARN_UNUSED;
-
- void normalDye(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- void normalOGLDye(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- private:
- /**
- * The order of the palettes, as well as their uppercase letter, is:
- *
- * Red, Green, Yellow, Blue, Magenta, White (or rather gray), Simple.
- */
- DyePalette *restrict mDyePalettes[dyePalateSize];
-};
-
-#endif // RESOURCES_DYE_DYE_H
diff --git a/src/resources/dye/dyecolor.h b/src/resources/dye/dyecolor.h
deleted file mode 100644
index 229f9d86b..000000000
--- a/src/resources/dye/dyecolor.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DYE_DYECOLOR_H
-#define RESOURCES_DYE_DYECOLOR_H
-
-#include "utils/buildhex.h"
-
-#include "localconsts.h"
-
-struct DyeColor final
-{
- DyeColor() noexcept2 :
- valueA(buildHex(0, 0, 0, 255)),
- valueS(buildHex(0, 0, 0, 0)),
- valueSOgl(buildHexOgl(0, 0, 0, 0))
- {
- value[3] = 255;
- }
-
- DyeColor(const uint8_t r,
- const uint8_t g,
- const uint8_t b) noexcept2 :
- valueA(buildHex(r, g, b, 255)),
- valueS(buildHex(r, g, b, 0)),
- valueSOgl(buildHexOgl(0, b, g, r))
- {
- value[0] = r;
- value[1] = g;
- value[2] = b;
- value[3] = 255;
- }
-
- DyeColor(const uint8_t r,
- const uint8_t g,
- const uint8_t b,
- const uint8_t a) noexcept2 :
- valueA(buildHex(r, g, b, a)),
- valueS(buildHex(r, g, b, 0)),
- valueSOgl(buildHexOgl(0, b, g, r))
- {
- value[0] = r;
- value[1] = g;
- value[2] = b;
- value[3] = a;
- }
-
- A_DEFAULT_COPY(DyeColor)
-
- void update()
- {
- valueA = buildHex(value[0], value[1], value[2], value[3]);
- valueS = buildHex(value[0], value[1], value[2], 0);
- valueSOgl = buildHexOgl(0, value[2], value[1], value[0]);
- }
-
- union
- {
- uint8_t value[4];
- uint32_t valueAOgl;
- };
- uint32_t valueA;
- uint32_t valueS;
- uint32_t valueSOgl;
-};
-
-#endif // RESOURCES_DYE_DYECOLOR_H
diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp
deleted file mode 100644
index 0e0784d63..000000000
--- a/src/resources/dye/dyepalette.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/dye/dyepalette.h"
-
-#include "logger.h"
-
-#ifndef DYECMD
-#include "resources/db/palettedb.h"
-#endif // DYECMD
-
-#include "utils/stringutils.h"
-
-#ifndef USE_SDL2
-#include <cmath>
-#endif // USE_SDL2
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#ifdef SIMD_SUPPORTED
-#include "utils/cpu.h"
-#endif // SIMD_SUPPORTED
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-DyeFunctionPtr DyePalette::funcReplaceSColor = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceSColorSse2 = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceSColorAvx2 = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceAColor = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceAColorSse2 = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceAColorAvx2 = nullptr;
-
-#ifdef USE_OPENGL
-DyeFunctionPtr DyePalette::funcReplaceSOGLColor = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceSOGLColorSse2 = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceSOGLColorAvx2 = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceAOGLColor = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceAOGLColorSse2 = nullptr;
-DyeFunctionPtr DyePalette::funcReplaceAOGLColorAvx2 = nullptr;
-#endif // USE_OPENGL
-
-DyePalette::DyePalette(const std::string &restrict description,
- const uint8_t blockSize) :
- mColors()
-{
- const size_t size = CAST_SIZE(description.length());
- if (size == 0)
- return;
-
- StringVect parts;
- splitToStringVector(parts, description.substr(1), ',');
- if (description[0] == '#')
- {
- FOR_EACH (StringVectCIter, it, parts)
- {
- DyeColor color(0, 0, 0, 0);
- hexToColor(*it, blockSize, color);
- mColors.push_back(color);
- }
- return;
- }
-#ifndef DYECMD
- else if (description[0] == '@')
- {
- uint8_t alpha = 255;
- FOR_EACH (StringVectCIter, it, parts)
- {
- const std::string str = *it;
- if (str.empty())
- continue;
- if (str[0] == '+')
- {
- if (str.size() != 3)
- continue;
- alpha = CAST_U8((hexDecode(str[1]) << 4) + hexDecode(str[2]));
- continue;
- }
- const DyeColor *const color = PaletteDB::getColor(str);
- if (color != nullptr)
- {
- DyeColor color2 = *color;
- color2.value[3] = alpha;
- mColors.push_back(color2);
- }
- else
- {
- DyeColor color2(0, 0, 0, 0);
- hexToColor(str, blockSize, color2);
- mColors.push_back(color2);
- }
- }
- return;
- }
-#endif // DYECMD
-
- logger->log("Error, invalid embedded palette: %s", description.c_str());
-}
-
-void DyePalette::hexToColor(const std::string &restrict hexStr,
- const uint8_t blockSize,
- DyeColor &color) noexcept2
-{
- for (size_t i = 0, colorIdx = 0;
- i < blockSize && colorIdx < 4;
- i += 2, colorIdx ++)
- {
- color.value[colorIdx] = CAST_U8((
- hexDecode(hexStr[i]) << 4)
- + hexDecode(hexStr[i + 1]));
- }
- color.update();
-}
-
-unsigned int DyePalette::hexDecode(const signed char c) noexcept2
-{
- if ('0' <= c && c <= '9')
- return c - '0';
- else if ('A' <= c && c <= 'F')
- return c - 'A' + 10;
- else if ('a' <= c && c <= 'f')
- return c - 'a' + 10;
- else
- return 0;
-}
-
-void DyePalette::getColor(const unsigned int intensity,
- unsigned int (&restrict color)[3]) const restrict2
-{
- if (intensity == 0)
- {
- color[0] = 0;
- color[1] = 0;
- color[2] = 0;
- return;
- }
-
- const int last = CAST_S32(mColors.size());
- if (last == 0)
- return;
-
- const int intLast = intensity * last;
- const int i = intLast / 255;
- const int t = intLast % 255;
-
- int j = t != 0 ? i : i - 1;
-
- if (j >= last)
- j = 0;
-
- // Get the exact color if any, the next color otherwise.
- const DyeColor &colorJ = mColors[j];
- const int r2 = colorJ.value[0];
- const int g2 = colorJ.value[1];
- const int b2 = colorJ.value[2];
-
- if (t == 0)
- {
- // Exact color.
- color[0] = r2;
- color[1] = g2;
- color[2] = b2;
- return;
- }
-
- // Get the previous color. First color is implicitly black.
- if (i > 0 && i < last + 1)
- {
- const DyeColor &colorI = mColors[i - 1];
- const int t2 = 255 - t;
- // Perform a linear interpolation.
- color[0] = (t2 * colorI.value[0] + t * r2) / 255;
- color[1] = (t2 * colorI.value[1] + t * g2) / 255;
- color[2] = (t2 * colorI.value[2] + t * b2) / 255;
- }
- else
- {
- // Perform a linear interpolation.
- color[0] = (t * r2) / 255;
- color[1] = (t * g2) / 255;
- color[2] = (t * b2) / 255;
- }
-}
-
-void DyePalette::getColor(double intensity,
- int (&restrict color)[3]) const restrict2
-{
- // Nothing to do here
- if (mColors.empty())
- return;
-
- // Force range
- if (intensity > 1.0)
- intensity = 1.0;
- else if (intensity < 0.0)
- intensity = 0.0;
-
- // Scale up
- intensity *= static_cast<double>(mColors.size() - 1);
-
- // Color indices
- const int i = CAST_S32(floor(intensity));
- const int j = CAST_S32(ceil(intensity));
- const DyeColor &colorI = mColors[i];
-
- if (i == j)
- {
- // Exact color.
- color[0] = colorI.value[0];
- color[1] = colorI.value[1];
- color[2] = colorI.value[2];
- return;
- }
-
- intensity -= i;
- const double rest = 1 - intensity;
- const DyeColor &colorJ = mColors[j];
-
- // Perform the interpolation.
- color[0] = CAST_S32(rest * colorI.value[0] +
- intensity * colorJ.value[0]);
- color[1] = CAST_S32(rest * colorI.value[1] +
- intensity * colorJ.value[1]);
- color[2] = CAST_S32(rest * colorI.value[2] +
- intensity * colorJ.value[2]);
-}
-
-void DyePalette::initFunctions()
-{
-#ifdef SIMD_SUPPORTED
- const uint32_t flags = Cpu::getFlags();
- if ((flags & Cpu::FEATURE_AVX2) != 0u)
- {
- funcReplaceSColor = &DyePalette::replaceSColorAvx2;
- funcReplaceSColorAvx2 = &DyePalette::replaceSColorAvx2;
- funcReplaceSColorSse2 = &DyePalette::replaceSColorSse2;
- funcReplaceAColor = &DyePalette::replaceAColorAvx2;
- funcReplaceAColorAvx2 = &DyePalette::replaceAColorAvx2;
- funcReplaceAColorSse2 = &DyePalette::replaceAColorSse2;
-
-#ifdef USE_OPENGL
- funcReplaceSOGLColor = &DyePalette::replaceSOGLColorAvx2;
- funcReplaceSOGLColorAvx2 = &DyePalette::replaceSOGLColorAvx2;
- funcReplaceSOGLColorSse2 = &DyePalette::replaceSOGLColorSse2;
- funcReplaceAOGLColor = &DyePalette::replaceAOGLColorAvx2;
- funcReplaceAOGLColorAvx2 = &DyePalette::replaceAOGLColorAvx2;
- funcReplaceAOGLColorSse2 = &DyePalette::replaceAOGLColorSse2;
-#endif // USE_OPENGL
- }
- else if ((flags & Cpu::FEATURE_SSE2) != 0u)
- {
- funcReplaceSColor = &DyePalette::replaceSColorSse2;
- funcReplaceSColorAvx2 = &DyePalette::replaceSColorSse2;
- funcReplaceSColorSse2 = &DyePalette::replaceSColorSse2;
- funcReplaceAColor = &DyePalette::replaceAColorSse2;
- funcReplaceAColorAvx2 = &DyePalette::replaceAColorSse2;
- funcReplaceAColorSse2 = &DyePalette::replaceAColorSse2;
-
-#ifdef USE_OPENGL
- funcReplaceSOGLColor = &DyePalette::replaceSOGLColorSse2;
- funcReplaceSOGLColorAvx2 = &DyePalette::replaceSOGLColorSse2;
- funcReplaceSOGLColorSse2 = &DyePalette::replaceSOGLColorSse2;
- funcReplaceAOGLColor = &DyePalette::replaceAOGLColorSse2;
- funcReplaceAOGLColorAvx2 = &DyePalette::replaceAOGLColorSse2;
- funcReplaceAOGLColorSse2 = &DyePalette::replaceAOGLColorSse2;
-#endif // USE_OPENGL
- }
- else
-#endif // SIMD_SUPPORTED
- {
- funcReplaceSColor = &DyePalette::replaceSColorDefault;
- funcReplaceSColorAvx2 = &DyePalette::replaceSColorDefault;
- funcReplaceSColorSse2 = &DyePalette::replaceSColorDefault;
- funcReplaceAColor = &DyePalette::replaceAColorDefault;
- funcReplaceAColorAvx2 = &DyePalette::replaceAColorDefault;
- funcReplaceAColorSse2 = &DyePalette::replaceAColorDefault;
-
-#ifdef USE_OPENGL
- funcReplaceSOGLColor = &DyePalette::replaceSOGLColorDefault;
- funcReplaceSOGLColorAvx2 = &DyePalette::replaceSOGLColorDefault;
- funcReplaceSOGLColorSse2 = &DyePalette::replaceSOGLColorDefault;
- funcReplaceAOGLColor = &DyePalette::replaceAOGLColorDefault;
- funcReplaceAOGLColorAvx2 = &DyePalette::replaceAOGLColorDefault;
- funcReplaceAOGLColorSse2 = &DyePalette::replaceAOGLColorDefault;
-#endif // USE_OPENGL
- }
-}
diff --git a/src/resources/dye/dyepalette.h b/src/resources/dye/dyepalette.h
deleted file mode 100644
index 2db7bd13b..000000000
--- a/src/resources/dye/dyepalette.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DYE_DYEPALETTE_H
-#define RESOURCES_DYE_DYEPALETTE_H
-
-#include "resources/dye/dyecolor.h"
-
-#include "utils/vector.h"
-
-#include "resources/dye/dyepaletteptr.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-#define DYEPALETTE(palette, color) \
- ((palette).*DyePalette::funcReplace##color)
-
-#define DYEPALETTEP(palette, color) \
- ((palette)->*DyePalette::funcReplace##color)
-
-/**
- * Class for performing a linear interpolation between colors.
- */
-class DyePalette final
-{
- public:
- /**
- * Creates a palette based on the given string.
- * The string is either a file name or a sequence of hexadecimal RGB
- * values separated by ',' and starting with '#'.
- */
- DyePalette(const std::string &restrict pallete,
- const uint8_t blockSize);
-
- A_DELETE_COPY(DyePalette)
-
- /**
- * Gets a pixel color depending on its intensity. First color is
- * implicitly black (0, 0, 0).
- */
- void getColor(const unsigned int intensity,
- unsigned int (&restrict color)[3]) const restrict2;
-
- /**
- * Gets a pixel color depending on its intensity.
- */
- void getColor(double intensity,
- int (&restrict color)[3]) const restrict2;
-
- /**
- * replace colors for SDL for S dye.
- */
- void replaceSColorDefault(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for SDL for A dye.
- */
- void replaceAColorDefault(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
-#ifdef SIMD_SUPPORTED
- /**
- * replace colors for SDL for S dye.
- */
- __attribute__ ((target ("sse2")))
- void replaceSColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for SDL for S dye.
- */
- __attribute__ ((target ("avx2")))
- void replaceSColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for SDL for A dye.
- */
- __attribute__ ((target ("sse2")))
- void replaceAColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for SDL for A dye.
- */
- __attribute__ ((target ("avx2")))
- void replaceAColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-#endif // SIMD_SUPPORTED
-
-#ifdef USE_OPENGL
- /**
- * replace colors for OpenGL for S dye.
- */
- void replaceSOGLColorDefault(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-#ifdef SIMD_SUPPORTED
- /**
- * replace colors for OpenGL for A dye.
- */
- __attribute__ ((target ("avx2")))
- void replaceAOGLColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for OpenGL for S dye.
- */
- __attribute__ ((target ("sse2")))
- void replaceSOGLColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
- /**
- * replace colors for OpenGL for S dye.
- */
- __attribute__ ((target ("avx2")))
- void replaceSOGLColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
- /**
- * replace colors for OpenGL for A dye.
- */
- __attribute__ ((target ("sse2")))
- void replaceAOGLColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-#endif // SIMD_SUPPORTED
-
- /**
- * replace colors for OpenGL for A dye.
- */
- void replaceAOGLColorDefault(uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
-#endif // USE_OPENGL
-
- static unsigned int hexDecode(const signed char c)
- noexcept2 A_CONST A_WARN_UNUSED;
-
- static void hexToColor(const std::string &restrict hexStr,
- const uint8_t blockSize,
- DyeColor &color) noexcept2;
-
- static void initFunctions();
-
-#ifdef USE_OPENGL
- static DyeFunctionPtr funcReplaceSOGLColor;
- static DyeFunctionPtr funcReplaceSOGLColorSse2;
- static DyeFunctionPtr funcReplaceSOGLColorAvx2;
- static DyeFunctionPtr funcReplaceAOGLColor;
- static DyeFunctionPtr funcReplaceAOGLColorSse2;
- static DyeFunctionPtr funcReplaceAOGLColorAvx2;
-#endif // USE_OPENGL
-
- static DyeFunctionPtr funcReplaceSColor;
- static DyeFunctionPtr funcReplaceSColorSse2;
- static DyeFunctionPtr funcReplaceSColorAvx2;
- static DyeFunctionPtr funcReplaceAColor;
- static DyeFunctionPtr funcReplaceAColorSse2;
- static DyeFunctionPtr funcReplaceAColorAvx2;
-
-#ifndef UNITTESTS
- private:
-#endif // UNITTESTS
- STD_VECTOR<DyeColor> mColors;
-};
-
-#endif // RESOURCES_DYE_DYEPALETTE_H
diff --git a/src/resources/dye/dyepalette_replaceacolor.cpp b/src/resources/dye/dyepalette_replaceacolor.cpp
deleted file mode 100644
index 256efb8bb..000000000
--- a/src/resources/dye/dyepalette_replaceacolor.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/dye/dyepalette.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#ifdef SIMD_SUPPORTED
-// avx2
-#include <immintrin.h>
-#endif // SIMD_SUPPORTED
-
-#include "debug.h"
-
-void DyePalette::replaceAColorDefault(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if ((sz == 0u) || (pixels == nullptr))
- return;
- if ((sz % 2) != 0u)
- -- it_end;
-
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[3] << 24U)
- | (col.value[2] << 16U)
- | (col.value[1] << 8U)
- | (col.value[0]);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[3])
- | (col.value[2] << 8U)
- | (col.value[1] << 16U) |
- (col.value[0] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- p[0] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
- const unsigned int data = *pixels;
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[3] << 24U)
- | (col.value[2] << 16U)
- | (col.value[1] << 8U)
- | (col.value[0]);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[3])
- | (col.value[2] << 8U)
- | (col.value[1] << 16U) |
- (col.value[0] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- p[0] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
-}
-
-#ifdef SIMD_SUPPORTED
-/*
-static void print256(const char *const text, const __m256i &val);
-static void print256(const char *const text, const __m256i &val)
-{
- printf("%s 0x%016llx%016llx%016llx%016llx\n", text, val[0], val[1], val[2], val[3]);
-}
-*/
-
-__attribute__ ((target ("sse2")))
-void DyePalette::replaceAColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if ((sz == 0u) || (pixels == nullptr))
- return;
- if ((sz % 2) != 0u)
- -- it_end;
- const int mod = bufSize % 4;
- const int bufEnd = bufSize - mod;
-
- for (int ptr = 0; ptr < bufEnd; ptr += 4)
- {
-// __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>(pixels));
- __m128i base = _mm_loadu_si128(reinterpret_cast<__m128i*>(
- &pixels[ptr]));
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m128i newMask = _mm_set1_epi32(col2.valueA);
- __m128i cmpMask = _mm_set1_epi32(col.valueA);
- __m128i cmpRes = _mm_cmpeq_epi32(base, cmpMask);
- __m128i srcAnd = _mm_andnot_si128(cmpRes, base);
- __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
- base = _mm_or_si128(srcAnd, dstAnd);
-
- ++ it;
- }
-// _mm_store_si128(reinterpret_cast<__m128i*>(pixels), base);
- _mm_storeu_si128(reinterpret_cast<__m128i*>(&pixels[ptr]), base);
- }
-
- // complete end without simd
- for (int ptr = bufSize - mod; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- const unsigned int coldata = (col.value[3]) |
- (col.value[2] << 8U) |
- (col.value[1] << 16U) |
- (col.value[0] << 24U);
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- p[0] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-}
-
-__attribute__ ((target ("avx2")))
-void DyePalette::replaceAColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if ((sz == 0u) || (pixels == nullptr))
- return;
- if ((sz % 2) != 0u)
- -- it_end;
- const int mod = bufSize % 8;
- const int bufEnd = bufSize - mod;
-
- for (int ptr = 0; ptr < bufEnd; ptr += 8)
- {
-// __m256i base = _mm256_load_si256(reinterpret_cast<__m256i*>(pixels));
- __m256i base = _mm256_loadu_si256(reinterpret_cast<__m256i*>(
- &pixels[ptr]));
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m256i newMask = _mm256_set1_epi32(col2.valueA);
- __m256i cmpMask = _mm256_set1_epi32(col.valueA);
- __m256i cmpRes = _mm256_cmpeq_epi32(base, cmpMask);
- __m256i srcAnd = _mm256_andnot_si256(cmpRes, base);
- __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
- base = _mm256_or_si256(srcAnd, dstAnd);
-
- ++ it;
- }
-// _mm256_store_si256(reinterpret_cast<__m256i*>(pixels), base);
- _mm256_storeu_si256(reinterpret_cast<__m256i*>(&pixels[ptr]), base);
- }
-
- // complete end without simd
- for (int ptr = bufSize - mod; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- const unsigned int coldata = (col.value[3]) |
- (col.value[2] << 8U) |
- (col.value[1] << 16U) |
- (col.value[0] << 24U);
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- p[0] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-}
-
-#endif // SIMD_SUPPORTED
diff --git a/src/resources/dye/dyepalette_replaceaoglcolor.cpp b/src/resources/dye/dyepalette_replaceaoglcolor.cpp
deleted file mode 100644
index 4d4588bb5..000000000
--- a/src/resources/dye/dyepalette_replaceaoglcolor.cpp
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "resources/dye/dyepalette.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#ifdef SIMD_SUPPORTED
-// avx2
-#include <immintrin.h>
-#endif // SIMD_SUPPORTED
-
-#include "debug.h"
-
-void DyePalette::replaceAOGLColorDefault(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (sz == 0u || pixels == nullptr)
- return;
- if ((sz % 2) != 0u)
- -- it_end;
-
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24U)
- | (col.value[1] << 16U)
- | (col.value[2] << 8U)
- | col.value[3];
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8U)
- | (col.value[2] << 16U)
- | (col.value[3] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- p[3] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
- const unsigned int data = *pixels;
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24U)
- | (col.value[1] << 16U)
- | (col.value[2] << 8U)
- | col.value[3];
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8U)
- | (col.value[2] << 16U)
- | (col.value[3] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- p[3] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
-}
-
-#ifdef SIMD_SUPPORTED
-/*
-static void print256(const char *const text, const __m256i &val);
-static void print256(const char *const text, const __m256i &val)
-{
- printf("%s 0x%016llx%016llx%016llx%016llx\n", text, val[0], val[1], val[2], val[3]);
-}
-*/
-
-__attribute__ ((target ("sse2")))
-void DyePalette::replaceAOGLColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (sz == 0u || pixels == nullptr)
- return;
- if ((sz % 2) != 0u)
- -- it_end;
-
- if (bufSize >= 8)
- {
- for (int ptr = 0; ptr < bufSize; ptr += 4)
- {
-// __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>(
-// &pixels[ptr]));
- __m128i base = _mm_loadu_si128(reinterpret_cast<__m128i*>(
- &pixels[ptr]));
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m128i newMask = _mm_set1_epi32(col2.valueAOgl);
- __m128i cmpMask = _mm_set1_epi32(col.valueAOgl);
- __m128i cmpRes = _mm_cmpeq_epi32(base, cmpMask);
- __m128i srcAnd = _mm_andnot_si128(cmpRes, base);
- __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
- base = _mm_or_si128(srcAnd, dstAnd);
-
- ++ it;
- }
-// _mm_store_si128(reinterpret_cast<__m128i*>(&pixels[ptr]), base);
- _mm_storeu_si128(reinterpret_cast<__m128i*>(&pixels[ptr]), base);
- }
- }
- else
- {
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24U)
- | (col.value[1] << 16U)
- | (col.value[2] << 8U)
- | col.value[3];
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8U)
- | (col.value[2] << 16U)
- | (col.value[3] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- p[3] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
- const unsigned int data = *pixels;
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24U)
- | (col.value[1] << 16U)
- | (col.value[2] << 8U)
- | col.value[3];
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8U)
- | (col.value[2] << 16U)
- | (col.value[3] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- p[3] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
- }
-}
-
-__attribute__ ((target ("avx2")))
-void DyePalette::replaceAOGLColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (sz == 0u || pixels == nullptr)
- return;
- if ((sz % 2) != 0u)
- -- it_end;
-
- if (bufSize >= 8)
- {
- for (int ptr = 0; ptr < bufSize; ptr += 8)
- {
-// __m256i base = _mm256_load_si256(reinterpret_cast<__m256i*>(
-// &pixels[ptr]));
- __m256i base = _mm256_loadu_si256(reinterpret_cast<__m256i*>(
- &pixels[ptr]));
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m256i newMask = _mm256_set1_epi32(col2.valueAOgl);
- __m256i cmpMask = _mm256_set1_epi32(col.valueAOgl);
- __m256i cmpRes = _mm256_cmpeq_epi32(base, cmpMask);
- __m256i srcAnd = _mm256_andnot_si256(cmpRes, base);
- __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
- base = _mm256_or_si256(srcAnd, dstAnd);
-
- ++ it;
- }
-// _mm256_store_si256(reinterpret_cast<__m256i*>(&pixels[ptr]),
-// base);
- _mm256_storeu_si256(reinterpret_cast<__m256i*>(&pixels[ptr]),
- base);
- }
- }
- else
- {
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
- const unsigned int data = pixels[ptr];
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24U)
- | (col.value[1] << 16U)
- | (col.value[2] << 8U)
- | col.value[3];
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8U)
- | (col.value[2] << 16U)
- | (col.value[3] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- p[3] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
- const unsigned int data = *pixels;
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24U)
- | (col.value[1] << 16U)
- | (col.value[2] << 8U)
- | col.value[3];
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8U)
- | (col.value[2] << 16U)
- | (col.value[3] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- p[3] = col2.value[3];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
- }
-}
-
-#endif // SIMD_SUPPORTED
-#endif // USE_OPENGL
diff --git a/src/resources/dye/dyepalette_replacescolor.cpp b/src/resources/dye/dyepalette_replacescolor.cpp
deleted file mode 100644
index 1d1c2676e..000000000
--- a/src/resources/dye/dyepalette_replacescolor.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/dye/dyepalette.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#ifdef SIMD_SUPPORTED
-// avx2
-#include <immintrin.h>
-#endif // SIMD_SUPPORTED
-
-#include "debug.h"
-
-void DyePalette::replaceSColorDefault(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (sz == 0u || pixels == nullptr)
- return;
- if ((sz % 2) != 0u)
- -- it_end;
-
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = pixels[ptr] & 0x00ffffff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = pixels[ptr] & 0xffffff00;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[2] << 16U)
- | (col.value[1] << 8U) | (col.value[0]);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[2] << 8U)
- | (col.value[1] << 16U) | (col.value[0] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- break;
- }
- ++ it;
- }
- }
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++ pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = (*pixels) & 0x00ffffff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = (*pixels) & 0xffffff00;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[2] << 16U)
- | (col.value[1] << 8U) | (col.value[0]);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[2] << 8U)
- | (col.value[1] << 16U) | (col.value[0] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
-}
-
-#ifdef SIMD_SUPPORTED
-/*
-static void print256(const char *const text, const __m256i &val);
-static void print256(const char *const text, const __m256i &val)
-{
- printf("%s 0x%016llx%016llx%016llx%016llx\n", text, val[0], val[1], val[2], val[3]);
-}
-*/
-
-__attribute__ ((target ("sse2")))
-void DyePalette::replaceSColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (sz == 0u || pixels == nullptr)
- return;
- if ((sz % 2) != 0u)
- -- it_end;
- const int mod = bufSize % 8;
- const int bufEnd = bufSize - mod;
-
- for (int ptr = 0; ptr < bufEnd; ptr += 4)
- {
- __m128i mask = _mm_set1_epi32(0xffffff00);
-// __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>(pixels));
- __m128i base = _mm_loadu_si128(reinterpret_cast<__m128i*>(
- &pixels[ptr]));
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m128i base2 = _mm_and_si128(mask, base);
- __m128i newMask = _mm_set1_epi32(col2.valueS);
- __m128i cmpMask = _mm_set1_epi32(col.valueS);
- __m128i cmpRes = _mm_cmpeq_epi32(base2, cmpMask);
- cmpRes = _mm_and_si128(mask, cmpRes);
- __m128i srcAnd = _mm_andnot_si128(cmpRes, base);
- __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
- base = _mm_or_si128(srcAnd, dstAnd);
- ++ it;
- }
-// _mm_store_si128(reinterpret_cast<__m128i*>(pixels), base);
- _mm_storeu_si128(reinterpret_cast<__m128i*>(&pixels[ptr]), base);
- }
-
- // complete end without simd
- for (int ptr = bufSize - mod; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = pixels[ptr] & 0x00ffffff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = pixels[ptr] & 0xffffff00;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[2] << 16U)
- | (col.value[1] << 8U) | (col.value[0]);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[2] << 8U)
- | (col.value[1] << 16U) | (col.value[0] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-}
-
-__attribute__ ((target ("avx2")))
-void DyePalette::replaceSColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if (sz == 0u || pixels == nullptr)
- return;
- if ((sz % 2) != 0u)
- -- it_end;
- const int mod = bufSize % 8;
- const int bufEnd = bufSize - mod;
-
- for (int ptr = 0; ptr < bufEnd; ptr += 8)
- {
- __m256i mask = _mm256_set1_epi32(0xffffff00);
-// __m256i base = _mm256_load_si256(reinterpret_cast<__m256i*>(pixels));
- __m256i base = _mm256_loadu_si256(reinterpret_cast<__m256i*>(
- &pixels[ptr]));
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m256i base2 = _mm256_and_si256(mask, base);
- __m256i newMask = _mm256_set1_epi32(col2.valueS);
- __m256i cmpMask = _mm256_set1_epi32(col.valueS);
- __m256i cmpRes = _mm256_cmpeq_epi32(base2, cmpMask);
- cmpRes = _mm256_and_si256(mask, cmpRes);
- __m256i srcAnd = _mm256_andnot_si256(cmpRes, base);
- __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
- base = _mm256_or_si256(srcAnd, dstAnd);
- ++ it;
- }
-// _mm256_store_si256(reinterpret_cast<__m256i*>(pixels), base);
- _mm256_storeu_si256(reinterpret_cast<__m256i*>(&pixels[ptr]), base);
- }
-
- // complete end without simd
- for (int ptr = bufSize - mod; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = pixels[ptr] & 0x00ffffff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = pixels[ptr] & 0xffffff00;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[2] << 16U)
- | (col.value[1] << 8U) | (col.value[0]);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[2] << 8U)
- | (col.value[1] << 16U) | (col.value[0] << 24U);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[3] = col2.value[0];
- p[2] = col2.value[1];
- p[1] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-}
-
-#endif // SIMD_SUPPORTED
diff --git a/src/resources/dye/dyepalette_replacesoglcolor.cpp b/src/resources/dye/dyepalette_replacesoglcolor.cpp
deleted file mode 100644
index b5c2c621a..000000000
--- a/src/resources/dye/dyepalette_replacesoglcolor.cpp
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "resources/dye/dyepalette.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#ifdef SIMD_SUPPORTED
-// avx2
-#include <immintrin.h>
-#endif // SIMD_SUPPORTED
-
-#include "debug.h"
-
-void DyePalette::replaceSOGLColorDefault(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if ((sz == 0u) || (pixels == nullptr))
- return;
- if ((sz % 2) != 0u)
- -- it_end;
-
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = (pixels[ptr]) & 0xffffff00;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = (pixels[ptr]) & 0x00ffffff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24)
- | (col.value[1] << 16) | (col.value[2] << 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8) | (col.value[2] << 16);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = (*pixels) & 0xffffff00;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = (*pixels) & 0x00ffffff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24)
- | (col.value[1] << 16) | (col.value[2] << 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8) | (col.value[2] << 16);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
-}
-
-#ifdef SIMD_SUPPORTED
-/*
-static void print256(const char *const text, const __m256i &val);
-static void print256(const char *const text, const __m256i &val)
-{
- printf("%s 0x%016llx%016llx%016llx%016llx\n", text, val[0], val[1], val[2], val[3]);
-}
-*/
-
-__attribute__ ((target ("sse2")))
-void DyePalette::replaceSOGLColorSse2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if ((sz == 0u) || (pixels == nullptr))
- return;
- if ((sz % 2) != 0u)
- -- it_end;
-
- if (bufSize >= 8)
- {
- for (int ptr = 0; ptr < bufSize; ptr += 4)
- {
- __m128i mask = _mm_set1_epi32(0x00ffffff);
-// __m128i base = _mm_load_si128(reinterpret_cast<__m128i*>(
-// &pixels[ptr]));
- __m128i base = _mm_loadu_si128(reinterpret_cast<__m128i*>(
- &pixels[ptr]));
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m128i base2 = _mm_and_si128(mask, base);
- __m128i newMask = _mm_set1_epi32(col2.valueSOgl);
- __m128i cmpMask = _mm_set1_epi32(col.valueSOgl);
- __m128i cmpRes = _mm_cmpeq_epi32(base2, cmpMask);
- cmpRes = _mm_and_si128(mask, cmpRes);
- __m128i srcAnd = _mm_andnot_si128(cmpRes, base);
- __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
- base = _mm_or_si128(srcAnd, dstAnd);
- ++ it;
- }
-// _mm_store_si128(reinterpret_cast<__m128i*>(&pixels[ptr]), base);
- _mm_storeu_si128(reinterpret_cast<__m128i*>(&pixels[ptr]), base);
- }
- }
- else
- {
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = (pixels[ptr]) & 0xffffff00;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = (pixels[ptr]) & 0x00ffffff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24)
- | (col.value[1] << 16) | (col.value[2] << 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8) | (col.value[2] << 16);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = (*pixels) & 0xffffff00;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = (*pixels) & 0x00ffffff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24)
- | (col.value[1] << 16) | (col.value[2] << 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8) | (col.value[2] << 16);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
- }
-}
-
-__attribute__ ((target ("avx2")))
-void DyePalette::replaceSOGLColorAvx2(uint32_t *restrict pixels,
- const int bufSize) const restrict2
-{
- STD_VECTOR<DyeColor>::const_iterator it_end = mColors.end();
- const size_t sz = mColors.size();
- if ((sz == 0u) || (pixels == nullptr))
- return;
- if ((sz % 2) != 0u)
- -- it_end;
-
- if (bufSize >= 8)
- {
- for (int ptr = 0; ptr < bufSize; ptr += 8)
- {
- __m256i mask = _mm256_set1_epi32(0x00ffffff);
-// __m256i base = _mm256_load_si256(reinterpret_cast<__m256i*>(
-// &pixels[ptr]));
- __m256i base = _mm256_loadu_si256(reinterpret_cast<__m256i*>(
- &pixels[ptr]));
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
- __m256i base2 = _mm256_and_si256(mask, base);
- __m256i newMask = _mm256_set1_epi32(col2.valueSOgl);
- __m256i cmpMask = _mm256_set1_epi32(col.valueSOgl);
- __m256i cmpRes = _mm256_cmpeq_epi32(base2, cmpMask);
- cmpRes = _mm256_and_si256(mask, cmpRes);
- __m256i srcAnd = _mm256_andnot_si256(cmpRes, base);
- __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
- base = _mm256_or_si256(srcAnd, dstAnd);
- ++ it;
- }
-// _mm256_store_si256(reinterpret_cast<__m256i*>(&pixels[ptr]),
-// base);
- _mm256_storeu_si256(reinterpret_cast<__m256i*>(&pixels[ptr]),
- base);
- }
- }
- else
- {
-#ifdef ENABLE_CILKPLUS
- cilk_for (int ptr = 0; ptr < bufSize; ptr ++)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = (pixels[ptr]) & 0xffffff00;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = (pixels[ptr]) & 0x00ffffff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24)
- | (col.value[1] << 16) | (col.value[2] << 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8) | (col.value[2] << 16);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-
-#else // ENABLE_CILKPLUS
-
- for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize);
- pixels != p_end;
- ++pixels)
- {
- uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int data = (*pixels) & 0xffffff00;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int data = (*pixels) & 0x00ffffff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- STD_VECTOR<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24)
- | (col.value[1] << 16) | (col.value[2] << 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8) | (col.value[2] << 16);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- break;
- }
-
- ++ it;
- }
- }
-#endif // ENABLE_CILKPLUS
- }
-}
-
-#endif // SIMD_SUPPORTED
-#endif // USE_OPENGL
diff --git a/src/resources/dye/dyepaletteptr.h b/src/resources/dye/dyepaletteptr.h
deleted file mode 100644
index baf81549d..000000000
--- a/src/resources/dye/dyepaletteptr.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_DYE_DYEPALETTEPTR_H
-#define RESOURCES_DYE_DYEPALETTEPTR_H
-
-#include "localconsts.h"
-
-class DyePalette;
-
-typedef void (DyePalette::*DyeFunctionPtr) (uint32_t *restrict pixels,
- const int bufSize) const restrict2;
-
-#endif // RESOURCES_DYE_DYEPALETTEPTR_H
diff --git a/src/resources/effectdescription.h b/src/resources/effectdescription.h
deleted file mode 100644
index f5d57d552..000000000
--- a/src/resources/effectdescription.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Fate <fate.tmw@googlemail.com>
- * Copyright (C) 2008 Chuck Miller <shadowmil@gmail.com>
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_EFFECTDESCRIPTION_H
-#define RESOURCES_EFFECTDESCRIPTION_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct EffectDescription final
-{
- EffectDescription(const int id0,
- const std::string &gfx0,
- const std::string &sfx0,
- const std::string &sprite0) :
- id(id0),
- gfx(gfx0),
- sfx(sfx0),
- sprite(sprite0)
- { }
-
- A_DEFAULT_COPY(EffectDescription)
-
- int id;
- std::string gfx;
- std::string sfx;
- std::string sprite;
-};
-#endif // RESOURCES_EFFECTDESCRIPTION_H
diff --git a/src/resources/emoteinfo.h b/src/resources/emoteinfo.h
deleted file mode 100644
index d946d0709..000000000
--- a/src/resources/emoteinfo.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_EMOTEINFO_H
-#define RESOURCES_EMOTEINFO_H
-
-#include "utils/stringvector.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-struct EmoteSprite;
-
-struct EmoteInfo final
-{
- EmoteInfo() :
- sprites(),
- particles(),
- time(400),
- effectId(-1)
- { }
-
- A_DELETE_COPY(EmoteInfo)
-
- std::list<EmoteSprite*> sprites;
- StringVect particles;
- int time;
- int effectId;
-};
-
-#endif // RESOURCES_EMOTEINFO_H
diff --git a/src/resources/emotesprite.h b/src/resources/emotesprite.h
deleted file mode 100644
index 9347fad7e..000000000
--- a/src/resources/emotesprite.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_EMOTESPRITE_H
-#define RESOURCES_EMOTESPRITE_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class AnimatedSprite;
-
-struct EmoteSprite final
-{
- EmoteSprite() :
- sprite(nullptr),
- id(0),
- name()
- { }
-
- A_DELETE_COPY(EmoteSprite)
-
- const AnimatedSprite *sprite;
- int id;
- std::string name;
-};
-
-#endif // RESOURCES_EMOTESPRITE_H
diff --git a/src/resources/equipmentslots.h b/src/resources/equipmentslots.h
deleted file mode 100644
index f8b88db03..000000000
--- a/src/resources/equipmentslots.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_EQUIPMENTSLOTS_H
-#define RESOURCES_EQUIPMENTSLOTS_H
-
-#include "localconsts.h"
-
-struct EquipmentSlotMap final
-{
- EquipmentSlotMap() :
- name(nullptr),
- id(0)
- { }
-
- A_DELETE_COPY(EquipmentSlotMap)
-
- const char *const name;
- const int id;
-};
-
-#endif // RESOURCES_EQUIPMENTSLOTS_H
diff --git a/src/resources/fboinfo.h b/src/resources/fboinfo.h
deleted file mode 100644
index 4df115395..000000000
--- a/src/resources/fboinfo.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_FBOINFO_H
-#define RESOURCES_FBOINFO_H
-
-#ifdef USE_OPENGL
-
-#include "localconsts.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#else // ANDROID
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_opengl.h>
-PRAGMA48(GCC diagnostic pop)
-#if defined(__APPLE__)
-#include <OpenGL/glext.h>
-#elif !defined(__native_client__)
-#include <GL/glext.h>
-#endif // defined(__APPLE__)
-#endif // ANDROID
-
-struct FBOInfo final
-{
- constexpr2 FBOInfo() :
- fboId(0),
- textureId(0),
- rboId(0)
- {
- }
-
- A_DELETE_COPY(FBOInfo)
-
- GLuint fboId;
- GLuint textureId;
- GLuint rboId;
-};
-
-#endif // USE_OPENGL
-#endif // RESOURCES_FBOINFO_H
diff --git a/src/resources/frame.h b/src/resources/frame.h
deleted file mode 100644
index f7d6a069c..000000000
--- a/src/resources/frame.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_FRAME_H
-#define RESOURCES_FRAME_H
-
-#include "enums/resources/frametype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Image;
-
-/**
- * A single frame in an animation, with a delay and an offset.
- */
-struct Frame final
-{
- A_DEFAULT_COPY(Frame)
-
- Image *image;
- int delay;
- int offsetX;
- int offsetY;
- int rand;
- FrameTypeT type;
- std::string nextAction;
-};
-
-#endif // RESOURCES_FRAME_H
diff --git a/src/resources/groupinfo.cpp b/src/resources/groupinfo.cpp
deleted file mode 100644
index 665bd6162..000000000
--- a/src/resources/groupinfo.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/groupinfo.h"
-
-#include "debug.h"
-
-GroupInfo::GroupInfo() :
- mCommands(),
- mPermissions(),
- name(),
- longName(),
- badge(),
- showBadge(false)
-{
- for (size_t f = 0; f < CAST_SIZE(ServerCommandType::Max); f ++)
- mCommands[f] = ServerCommandEnable::No;
- for (size_t f = 0; f < CAST_SIZE(ServerPermissionType::Max); f ++)
- mPermissions[f] = Enable_false;
-}
diff --git a/src/resources/groupinfo.h b/src/resources/groupinfo.h
deleted file mode 100644
index b2cbf5854..000000000
--- a/src/resources/groupinfo.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_GROUPINFO_H
-#define RESOURCES_GROUPINFO_H
-
-#include "localconsts.h"
-
-#include "enums/resources/servercommandenable.h"
-#include "enums/resources/servercommandtype.h"
-#include "enums/resources/serverpermissiontype.h"
-
-#include "enums/simpletypes/enable.h"
-
-#include "utils/cast.h"
-
-#include <string>
-
-struct GroupInfo final
-{
- GroupInfo();
-
- A_DELETE_COPY(GroupInfo)
-
- ServerCommandEnable::Type mCommands[CAST_SIZE(ServerCommandType::Max)];
- Enable mPermissions[CAST_SIZE(ServerPermissionType::Max)];
- std::string name;
- std::string longName;
- std::string badge;
- bool showBadge;
-};
-
-#endif // RESOURCES_GROUPINFO_H
diff --git a/src/resources/horseinfo.h b/src/resources/horseinfo.h
deleted file mode 100644
index 1ff800186..000000000
--- a/src/resources/horseinfo.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_HORSEINFO_H
-#define RESOURCES_HORSEINFO_H
-
-#include "resources/sprite/spritereference.h"
-
-#include "resources/horseoffset.h"
-
-#include "localconsts.h"
-
-struct HorseInfo final
-{
- HorseInfo() :
- downSprites(),
- upSprites(),
- offsets()
- {
- for (int f = 0; f < 10; f ++)
- {
- offsets[f].upOffsetX = 0;
- offsets[f].upOffsetY = 0;
- offsets[f].downOffsetX = 0;
- offsets[f].downOffsetY = 0;
- offsets[f].riderOffsetX = 0;
- offsets[f].riderOffsetY = 0;
- }
- }
-
- A_DELETE_COPY(HorseInfo)
-
- STD_VECTOR<SpriteReference*> downSprites;
- STD_VECTOR<SpriteReference*> upSprites;
- HorseOffset offsets[10]; // by direction
-};
-
-#endif // RESOURCES_HORSEINFO_H
diff --git a/src/resources/horseoffset.h b/src/resources/horseoffset.h
deleted file mode 100644
index d68c0d0b0..000000000
--- a/src/resources/horseoffset.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_HORSEOFFSET_H
-#define RESOURCES_HORSEOFFSET_H
-
-#include "localconsts.h"
-
-struct HorseOffset final
-{
- HorseOffset() :
- upOffsetX(0),
- upOffsetY(0),
- downOffsetX(0),
- downOffsetY(0),
- riderOffsetX(0),
- riderOffsetY(0)
- { }
-
- A_DELETE_COPY(HorseOffset)
-
- int upOffsetX;
- int upOffsetY;
- int downOffsetX;
- int downOffsetY;
- int riderOffsetX;
- int riderOffsetY;
-};
-
-#endif // RESOURCES_HORSEOFFSET_H
diff --git a/src/resources/image/image.cpp b/src/resources/image/image.cpp
deleted file mode 100644
index ec17bbdf4..000000000
--- a/src/resources/image/image.cpp
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/image/image.h"
-
-#include "logger.h"
-
-#ifdef USE_OPENGL
-#include "resources/openglimagehelper.h"
-#endif // USE_OPENGL
-
-#include "resources/memorymanager.h"
-#include "resources/sdlimagehelper.h"
-
-#include "resources/image/subimage.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/cast.h"
-#include "utils/sdlcheckutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef USE_SDL2
-#include <SDL2_rotozoom.h>
-#else // USE_SDL2
-#include <SDL_rotozoom.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifdef UNITTESTS
-Image::Image(const int width,
- const int height) :
- Resource(),
-#ifdef USE_OPENGL
- mGLImage(0),
- mTexWidth(0),
- mTexHeight(0),
-#endif // USE_OPENGL
- mBounds(),
- mAlpha(1.0F),
- mSDLSurface(nullptr),
-#ifdef USE_SDL2
- mTexture(nullptr),
-#endif // USE_SDL2
- mAlphaChannel(nullptr),
- mAlphaCache(),
- mLoaded(false),
- mHasAlphaChannel(false),
- mUseAlphaCache(false),
- mIsAlphaVisible(true),
- mIsAlphaCalculated(false)
-{
- mBounds.x = 0;
- mBounds.y = 0;
- mBounds.w = width;
- mBounds.h = height;
-}
-#endif // UNITTESTS
-
-#ifdef USE_SDL2
-Image::Image(SDL_Texture *restrict const image,
- const int width, const int height) :
- Resource(),
-#ifdef USE_OPENGL
- mGLImage(0),
- mTexWidth(0),
- mTexHeight(0),
-#endif // USE_OPENGL
- mBounds(),
- mAlpha(1.0F),
- mSDLSurface(nullptr),
- mTexture(image),
- mAlphaChannel(nullptr),
- mAlphaCache(),
- mLoaded(false),
- mHasAlphaChannel(false),
- mUseAlphaCache(false),
- mIsAlphaVisible(true),
- mIsAlphaCalculated(false)
-{
-#ifdef DEBUG_IMAGES
- logger->log("created image: %p", this);
-#endif // DEBUG_IMAGES
-
- mBounds.x = 0;
- mBounds.y = 0;
-
- if (mTexture)
- {
- mBounds.w = CAST_U16(width);
- mBounds.h = CAST_U16(height);
-
- mLoaded = true;
- }
- else
- {
- mBounds.w = 0;
- mBounds.h = 0;
- }
-}
-#endif // USE_SDL2
-
-Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0,
- uint8_t *restrict const alphaChannel) :
- Resource(),
-#ifdef USE_OPENGL
- mGLImage(0),
- mTexWidth(0),
- mTexHeight(0),
-#endif // USE_OPENGL
- mBounds(),
- mAlpha(1.0F),
- mSDLSurface(image),
-#ifdef USE_SDL2
- mTexture(nullptr),
-#endif // USE_SDL2
- mAlphaChannel(alphaChannel),
- mAlphaCache(),
- mLoaded(false),
- mHasAlphaChannel(hasAlphaChannel0),
- mUseAlphaCache(SDLImageHelper::mEnableAlphaCache),
- mIsAlphaVisible(hasAlphaChannel0),
- mIsAlphaCalculated(false)
-{
-#ifdef DEBUG_IMAGES
- logger->log("created image: %p", static_cast<void*>(this));
-#endif // DEBUG_IMAGES
-
- mBounds.x = 0;
- mBounds.y = 0;
-
- if (mSDLSurface != nullptr)
- {
- mBounds.w = CAST_U16(mSDLSurface->w);
- mBounds.h = CAST_U16(mSDLSurface->h);
-
- mLoaded = true;
- }
- else
- {
- mBounds.w = 0;
- mBounds.h = 0;
- }
-}
-
-#ifdef USE_OPENGL
-Image::Image(const GLuint glimage, const int width, const int height,
- const int texWidth, const int texHeight) :
- Resource(),
- mGLImage(glimage),
- mTexWidth(texWidth),
- mTexHeight(texHeight),
- mBounds(),
- mAlpha(1.0F),
- mSDLSurface(nullptr),
-#ifdef USE_SDL2
- mTexture(nullptr),
-#endif // USE_SDL2
- mAlphaChannel(nullptr),
- mAlphaCache(),
- mLoaded(false),
- mHasAlphaChannel(true),
- mUseAlphaCache(false),
- mIsAlphaVisible(true),
- mIsAlphaCalculated(false)
-{
-#ifdef DEBUG_IMAGES
- logger->log("created image: %p", static_cast<void*>(this));
-#endif // DEBUG_IMAGES
-
- mBounds.x = 0;
- mBounds.y = 0;
- mBounds.w = CAST_U16(width);
- mBounds.h = CAST_U16(height);
-
- if (mGLImage != 0u)
- {
- mLoaded = true;
- }
-}
-#endif // USE_OPENGL
-
-Image::~Image()
-{
-#ifdef DEBUG_IMAGES
- logger->log("delete image: %p", static_cast<void*>(this));
- logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str());
-#endif // DEBUG_IMAGES
-
- unload();
-}
-
-void Image::SDLCleanCache()
-{
- for (std::map<float, SDL_Surface*>::iterator
- i = mAlphaCache.begin(), i_end = mAlphaCache.end();
- i != i_end; ++i)
- {
- if (mSDLSurface != i->second)
- ResourceManager::scheduleDelete(i->second);
- i->second = nullptr;
- }
- mAlphaCache.clear();
-}
-
-void Image::unload()
-{
- mLoaded = false;
-
- if (mSDLSurface != nullptr)
- {
- SDLCleanCache();
- // Free the image surface.
- MSDL_FreeSurface(mSDLSurface);
- mSDLSurface = nullptr;
-
- delete [] mAlphaChannel;
- mAlphaChannel = nullptr;
- }
-#ifdef USE_SDL2
- if (mTexture)
- {
- SDL_DestroyTexture(mTexture);
- mTexture = nullptr;
- }
-#endif // USE_SDL2
-
-#ifdef USE_OPENGL
- if (mGLImage != 0u)
- {
- glDeleteTextures(1, &mGLImage);
- mGLImage = 0;
-#ifdef DEBUG_OPENGL_LEAKS
- if (textures_count > 0)
- textures_count --;
-#endif // DEBUG_OPENGL_LEAKS
- }
-#endif // USE_OPENGL
-}
-
-bool Image::hasAlphaChannel() const
-{
- if (mLoaded)
- return mHasAlphaChannel;
-
-#ifdef USE_OPENGL
- if (OpenGLImageHelper::mUseOpenGL != RENDER_SOFTWARE)
- return true;
-#endif // USE_OPENGL
-
- return false;
-}
-
-SDL_Surface *Image::getByAlpha(const float alpha)
-{
- const std::map<float, SDL_Surface*>::const_iterator
- it = mAlphaCache.find(alpha);
- if (it != mAlphaCache.end())
- return (*it).second;
- return nullptr;
-}
-
-void Image::setAlpha(const float alpha)
-{
- if (mAlpha == alpha || !ImageHelper::mEnableAlpha)
- return;
-
- if (alpha < 0.0F || alpha > 1.0F)
- return;
-
- if (mSDLSurface != nullptr)
- {
- if (mUseAlphaCache)
- {
- SDL_Surface *surface = getByAlpha(mAlpha);
- if (surface == nullptr)
- {
- if (mAlphaCache.size() > 100)
- {
-#ifdef DEBUG_ALPHA_CACHE
- logger->log("cleanCache");
- for (std::map<float, SDL_Surface*>::const_iterator
- i = mAlphaCache.begin(), i_end = mAlphaCache.end();
- i != i_end; ++i)
- {
- logger->log("alpha: " + toString(i->first));
- }
-#endif // DEBUG_ALPHA_CACHE
-
- SDLCleanCache();
- }
- surface = mSDLSurface;
- if (surface != nullptr)
- mAlphaCache[mAlpha] = surface;
- }
- else
- {
- logger->log("cache bug");
- }
-
- surface = getByAlpha(alpha);
- if (surface != nullptr)
- {
- if (mSDLSurface == surface)
- logger->log("bug");
- mAlphaCache.erase(alpha);
- mSDLSurface = surface;
- mAlpha = alpha;
- return;
- }
- mSDLSurface = SDLImageHelper::SDLDuplicateSurface(mSDLSurface);
- if (mSDLSurface == nullptr)
- return;
- }
-
- mAlpha = alpha;
-
- if (!mHasAlphaChannel)
- {
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(mSDLSurface,
- CAST_U8(255 * mAlpha));
-#else // USE_SDL2
-
- // Set the alpha value this image is drawn at
- SDL_SetAlpha(mSDLSurface, SDL_SRCALPHA,
- CAST_U8(255 * mAlpha));
-#endif // USE_SDL2
- }
- else
- {
- if (SDL_MUSTLOCK(mSDLSurface))
- SDL_LockSurface(mSDLSurface);
-
- const int bx = mBounds.x;
- const int by = mBounds.y;
- const int bw = mBounds.w;
- const int bh = mBounds.h;
- const int bxw = bx + bw;
- const int sw = mSDLSurface->w;
- const int maxHeight = std::min(by + bh, mSDLSurface->h);
- const int maxWidth = std::min(bxw, sw);
- const int i1 = by * sw + bx;
- const SDL_PixelFormat * const fmt = mSDLSurface->format;
- const uint32_t amask = fmt->Amask;
- const uint32_t invMask = ~fmt->Amask;
- const uint8_t aloss = fmt->Aloss;
- const uint8_t ashift = fmt->Ashift;
-
- if ((bx == 0) && bxw == sw)
- {
- const int i2 = (maxHeight - 1) * sw + maxWidth - 1;
- for (int i = i1; i <= i2; i++)
- {
- const uint8_t sourceAlpha = mAlphaChannel[i];
- if (sourceAlpha > 0)
- {
- const uint8_t a = CAST_U8(
- static_cast<float>(sourceAlpha) * mAlpha);
-
- uint32_t c = (static_cast<uint32_t*>(
- mSDLSurface->pixels))[i];
- c &= invMask;
- c |= ((a >> aloss) << ashift & amask);
- (static_cast<uint32_t*>(mSDLSurface->pixels))[i] = c;
- }
- }
- }
- else
- {
- for (int y = by; y < maxHeight; y ++)
- {
- const int idx = y * sw;
- const int x1 = idx + bx;
- const int x2 = idx + maxWidth;
- for (int i = x1; i < x2; i ++)
- {
- const uint8_t sourceAlpha = mAlphaChannel[i];
- if (sourceAlpha > 0)
- {
- const uint8_t a = CAST_U8(
- static_cast<float>(sourceAlpha) * mAlpha);
-
- uint32_t c = (static_cast<uint32_t*>(
- mSDLSurface->pixels))[i];
- c &= invMask;
- c |= ((a >> aloss) << ashift & amask);
- (static_cast<uint32_t*>(
- mSDLSurface->pixels))[i] = c;
- }
- }
- }
- }
-
- if (SDL_MUSTLOCK(mSDLSurface))
- SDL_UnlockSurface(mSDLSurface);
- }
- }
-#ifdef USE_SDL2
- else if (mTexture)
- {
- mAlpha = alpha;
- SDL_SetTextureAlphaMod(mTexture,
- CAST_U8(255 * mAlpha));
- }
-#endif // USE_SDL2
- else
- {
- mAlpha = alpha;
- }
-}
-
-Image* Image::SDLgetScaledImage(const int width, const int height) const
-{
- // No scaling on incorrect new values.
- if (width == 0 || height == 0)
- return nullptr;
-
- // No scaling when there is ... no different given size ...
- if (width == mBounds.w && height == mBounds.h)
- return nullptr;
-
- Image* scaledImage = nullptr;
-
- if (mSDLSurface != nullptr)
- {
- SDL_Surface *const scaledSurface = zoomSurface(mSDLSurface,
- static_cast<double>(width) / mBounds.w,
- static_cast<double>(height) / mBounds.h,
- 1);
-
- // The load function takes care of the SDL<->OpenGL implementation
- // and about freeing the given SDL_surface*.
- if (scaledSurface != nullptr)
- {
- scaledImage = imageHelper->loadSurface(scaledSurface);
- MSDL_FreeSurface(scaledSurface);
- }
- }
- return scaledImage;
-}
-
-Image *Image::getSubImage(const int x, const int y,
- const int width, const int height)
-{
- // Create a new clipped sub-image
-#ifdef USE_OPENGL
- const RenderType mode = OpenGLImageHelper::mUseOpenGL;
- if (mode == RENDER_NORMAL_OPENGL ||
- mode == RENDER_SAFE_OPENGL ||
- mode == RENDER_GLES_OPENGL ||
- mode == RENDER_GLES2_OPENGL ||
- mode == RENDER_MODERN_OPENGL)
- {
- return new SubImage(this,
- mGLImage,
- x, y,
- width, height,
- mTexWidth, mTexHeight);
- }
-#endif // USE_OPENGL
-
-#ifdef USE_SDL2
-#ifndef USE_OPENGL
- const RenderType mode = ImageHelper::mUseOpenGL;
-#endif // USE_OPENGL
-
- if (mode == RENDER_SOFTWARE)
- return new SubImage(this, mSDLSurface, x, y, width, height);
- else
- return new SubImage(this, mTexture, x, y, width, height);
-#else // USE_SDL2
-
- return new SubImage(this, mSDLSurface, x, y, width, height);
-#endif // USE_SDL2
-}
-
-void Image::SDLTerminateAlphaCache()
-{
- SDLCleanCache();
- mUseAlphaCache = false;
-}
-
-int Image::calcMemoryLocal() const
-{
- // +++ this calculation can be wrong for SDL2
- int sz = static_cast<int>(sizeof(Image) +
- sizeof(std::map<float, SDL_Surface*>)) +
- Resource::calcMemoryLocal();
- if (mSDLSurface != nullptr)
- {
- sz += CAST_S32(mAlphaCache.size()) *
- memoryManager.getSurfaceSize(mSDLSurface);
- }
- return sz;
-}
-
-#ifdef USE_OPENGL
-void Image::decRef()
-{
- if ((mGLImage != 0u) && mRefCount <= 1)
- OpenGLImageHelper::invalidate(mGLImage);
- Resource::decRef();
-}
-#endif // USE_OPENGL
diff --git a/src/resources/image/image.h b/src/resources/image/image.h
deleted file mode 100644
index 1da834bb1..000000000
--- a/src/resources/image/image.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_IMAGE_H
-#define RESOURCES_IMAGE_H
-
-#include "localconsts.h"
-
-#include "enums/resources/imagetype.h"
-
-#include "resources/resource.h"
-
-#ifdef USE_OPENGL
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#else // ANDROID
-#ifndef USE_SDL2
-#define GL_GLEXT_PROTOTYPES 1
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_opengl.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // ANDROID
-#endif // USE_OPENGL
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef USE_SDL2
-#include <SDL_render.h>
-#else // USE_SDL2
-#include <SDL_video.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include <map>
-
-/**
- * Defines a class for loading and storing images.
- */
-class Image notfinal : public Resource
-{
- friend class CompoundSprite;
- friend class Graphics;
- friend class ImageHelper;
- friend class SDLGraphics;
- friend class SDLImageHelper;
- friend class SurfaceGraphics;
-#ifdef USE_SDL2
- friend class SDL2SoftwareGraphics;
- friend class SDL2SoftwareImageHelper;
- friend class SurfaceImageHelper;
-#endif // USE_SDL2
- friend class TestLauncher;
-#ifdef USE_OPENGL
- friend class AtlasManager;
- friend class MobileOpenGL2Graphics;
- friend class MobileOpenGLGraphics;
- friend class ModernOpenGLGraphics;
- friend class NormalOpenGLGraphics;
- friend class NullOpenGLGraphics;
- friend class SafeOpenGLGraphics;
- friend class OpenGLImageHelper;
-#ifndef ANDROID
- friend class SafeOpenGLImageHelper;
-#endif // ANDROID
-#endif // USE_OPENGL
-
- public:
-#ifdef UNITTESTS
- Image(const int width,
- const int height);
-#endif // UNITTESTS
-
- A_DELETE_COPY(Image)
-
- /**
- * Destructor.
- */
- virtual ~Image();
-
- /**
- * Frees the resources created by SDL.
- */
- void unload();
-
- /**
- * Tells is the image is loaded
- */
- bool isLoaded() const noexcept2 A_WARN_UNUSED
- { return mLoaded; }
-
- /**
- * Returns the width of the image.
- */
- inline int getWidth() const noexcept2 A_WARN_UNUSED A_INLINE
- { return mBounds.w; }
-
- /**
- * Returns the height of the image.
- */
- inline int getHeight() const noexcept2 A_WARN_UNUSED A_INLINE
- { return mBounds.h; }
-
- /**
- * Tells if the image has got an alpha channel
- * @return true if it's true, false otherwise.
- */
- bool hasAlphaChannel() const A_WARN_UNUSED;
-
- /**
- * Sets the alpha value of this image.
- */
- virtual void setAlpha(const float alpha);
-
- /**
- * Creates a new image with the desired clipping rectangle.
- *
- * @return <code>NULL</code> if creation failed and a valid
- * object otherwise.
- */
- virtual Image *getSubImage(const int x, const int y,
- const int width,
- const int height) A_WARN_UNUSED;
-
-
- // SDL only public functions
-
- /**
- * Gets an scaled instance of an image.
- *
- * @param width The desired width of the scaled image.
- * @param height The desired height of the scaled image.
- *
- * @return A new Image* object.
- */
- Image* SDLgetScaledImage(const int width,
- const int height) const A_WARN_UNUSED;
-
- /**
- * Get the alpha Channel of a SDL surface.
- */
- uint8_t *SDLgetAlphaChannel() const noexcept2 A_WARN_UNUSED
- { return mAlphaChannel; }
-
- void SDLCleanCache();
-
- void SDLTerminateAlphaCache();
-
-#ifdef USE_OPENGL
- int getTextureWidth() const noexcept2 A_WARN_UNUSED
- { return mTexWidth; }
-
- int getTextureHeight() const noexcept2 A_WARN_UNUSED
- { return mTexHeight; }
-
- GLuint getGLImage() const noexcept2 A_WARN_UNUSED
- { return mGLImage; }
-
- void decRef() override;
-
- GLuint mGLImage;
- int mTexWidth;
- int mTexHeight;
-#endif // USE_OPENGL
-
- bool isHasAlphaChannel() const noexcept2 A_WARN_UNUSED
- { return mHasAlphaChannel; }
-
- bool isAlphaVisible() const noexcept2 A_WARN_UNUSED
- { return mIsAlphaVisible; }
-
- void setAlphaVisible(const bool b)
- { mIsAlphaVisible = b; }
-
- bool isAlphaCalculated() const noexcept2 A_WARN_UNUSED
- { return mIsAlphaCalculated; }
-
- void setAlphaCalculated(const bool b) noexcept2
- { mIsAlphaCalculated = b; }
-
- SDL_Surface* getSDLSurface() noexcept2 A_WARN_UNUSED
- { return mSDLSurface; }
-
- int calcMemoryLocal() const override;
-
- virtual ImageTypeT getType() const noexcept2 A_WARN_UNUSED
- { return ImageType::Image; }
-
- SDL_Rect mBounds;
-
- float mAlpha;
-
- protected:
- // -----------------------
- // SDL protected members
- // -----------------------
-
- /** SDL Constructor */
- Image(SDL_Surface *restrict const image, const bool hasAlphaChannel,
- uint8_t *restrict const alphaChannel = nullptr);
-
-#ifdef USE_SDL2
- Image(SDL_Texture *restrict const image,
- const int width, const int height);
-#endif // USE_SDL2
-
- SDL_Surface *getByAlpha(const float alpha) A_WARN_UNUSED;
-
- SDL_Surface *mSDLSurface;
-#ifdef USE_SDL2
- SDL_Texture *mTexture;
-#endif // USE_SDL2
-
- /** Alpha Channel pointer used for 32bit based SDL surfaces */
- uint8_t *mAlphaChannel;
-
- std::map<float, SDL_Surface*> mAlphaCache;
-
- bool mLoaded;
- bool mHasAlphaChannel;
- bool mUseAlphaCache;
- bool mIsAlphaVisible;
- bool mIsAlphaCalculated;
-
- // -----------------------
- // OpenGL protected members
- // -----------------------
-#ifdef USE_OPENGL
- /**
- * OpenGL Constructor.
- */
- Image(const GLuint glimage, const int width, const int height,
- const int texWidth, const int texHeight);
-#endif // USE_OPENGL
-};
-
-#endif // RESOURCES_IMAGE_H
diff --git a/src/resources/image/subimage.cpp b/src/resources/image/subimage.cpp
deleted file mode 100644
index 0b14b788e..000000000
--- a/src/resources/image/subimage.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/image/subimage.h"
-
-#include "utils/cast.h"
-
-#ifdef DEBUG_IMAGES
-#include "logger.h"
-#endif // DEBUG_IMAGES
-
-#include "debug.h"
-
-#ifdef USE_SDL2
-SubImage::SubImage(Image *const parent,
- SDL_Texture *const image,
- const int x, const int y,
- const int width, const int height) :
- Image(image, width, height),
- mInternalBounds(),
- mParent(parent)
-{
- if (mParent)
- {
- mParent->incRef();
- mParent->SDLTerminateAlphaCache();
- mHasAlphaChannel = mParent->hasAlphaChannel();
- mIsAlphaVisible = mHasAlphaChannel;
- mAlphaChannel = mParent->SDLgetAlphaChannel();
- mSource = parent->mIdPath;
-#ifdef DEBUG_IMAGES
- logger->log("set name2 %p, %s", this, mSource.c_str());
-#endif // DEBUG_IMAGES
-#ifdef DEBUG_BIND_TEXTURE
- mIdPath = parent->mIdPath;
-#endif // DEBUG_BIND_TEXTURE
- }
- else
- {
- mHasAlphaChannel = false;
- mIsAlphaVisible = false;
- mAlphaChannel = nullptr;
- }
-
- // Set up the rectangle.
- mBounds.x = CAST_S16(x);
- mBounds.y = CAST_S16(y);
- mBounds.w = CAST_U16(width);
- mBounds.h = CAST_U16(height);
- 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;
-}
-#endif // USE_SDL2
-
-SubImage::SubImage(Image *const parent,
- SDL_Surface *const image,
- const int x, const int y,
- const int width, const int height) :
- Image(image, false),
- mInternalBounds(),
- mParent(parent)
-{
- if (mParent != nullptr)
- {
- mParent->incRef();
- mParent->SDLTerminateAlphaCache();
- mHasAlphaChannel = mParent->hasAlphaChannel();
- mIsAlphaVisible = mHasAlphaChannel;
- mAlphaChannel = mParent->SDLgetAlphaChannel();
- mSource = parent->mIdPath;
-#ifdef DEBUG_IMAGES
- logger->log("set name2 %p, %s", static_cast<void*>(this),
- mSource.c_str());
-#endif // DEBUG_IMAGES
-#ifdef DEBUG_BIND_TEXTURE
- mIdPath = parent->mIdPath;
-#endif // DEBUG_BIND_TEXTURE
- }
- else
- {
- mHasAlphaChannel = false;
- mIsAlphaVisible = false;
- mAlphaChannel = nullptr;
- }
-
- // Set up the rectangle.
- mBounds.x = CAST_S16(x);
- mBounds.y = CAST_S16(y);
- mBounds.w = CAST_U16(width);
- mBounds.h = CAST_U16(height);
- if (mParent != nullptr)
- {
- 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;
-}
-
-#ifdef USE_OPENGL
-SubImage::SubImage(Image *const parent,
- const GLuint image,
- const int x, const int y,
- const int width, const int height,
- const int texWidth, const int texHeight) :
- Image(image, width, height, texWidth, texHeight),
- mInternalBounds(),
- mParent(parent)
-{
- if (mParent != nullptr)
- mParent->incRef();
-
- // Set up the rectangle.
- mBounds.x = CAST_S16(x);
- mBounds.y = CAST_S16(y);
- mBounds.w = CAST_U16(width);
- mBounds.h = CAST_U16(height);
- if (mParent != nullptr)
- {
- mInternalBounds.x = mParent->mBounds.x;
- mInternalBounds.y = mParent->mBounds.y;
- mInternalBounds.w = mParent->mBounds.w;
- mInternalBounds.h = mParent->mBounds.h;
- mSource = parent->mIdPath;
-#ifdef DEBUG_IMAGES
- logger->log("set name2 %p, %s", static_cast<void*>(this),
- mSource.c_str());
-#endif // DEBUG_IMAGES
-#ifdef DEBUG_BIND_TEXTURE
- mIdPath = parent->mIdPath;
-#endif // DEBUG_BIND_TEXTURE
- }
- else
- {
- mInternalBounds.x = 0;
- mInternalBounds.y = 0;
- mInternalBounds.w = 1;
- mInternalBounds.h = 1;
- }
- mIsAlphaVisible = mHasAlphaChannel;
-}
-#endif // USE_OPENGL
-
-SubImage::~SubImage()
-{
-#ifdef DEBUG_IMAGES
- logger->log("delete subimage: %p", static_cast<void*>(this));
- logger->log(" %s, %s", mIdPath.c_str(), mSource.c_str());
-#endif // DEBUG_IMAGES
- // Avoid destruction of the image
- mSDLSurface = nullptr;
- // Avoid possible destruction of its alpha channel
- mAlphaChannel = nullptr;
-#ifdef USE_SDL2
- // Avoid destruction of texture
- mTexture = nullptr;
-#endif // USE_SDL2
-#ifdef USE_OPENGL
- mGLImage = 0;
-#endif // USE_OPENGL
- if (mParent != nullptr)
- {
-#ifdef DEBUG_IMAGES
- logger->log("decref from subminage: %p, parent: %p",
- static_cast<void*>(this), static_cast<void*>(mParent));
-#endif // DEBUG_IMAGES
-
- mParent->decRef();
- mParent = nullptr;
- }
-}
-
-Image *SubImage::getSubImage(const int x, const int y,
- const int w, const int h)
-{
- if (mParent != nullptr)
- return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
- return nullptr;
-}
-
-#ifdef USE_OPENGL
-void SubImage::decRef()
-{
- Resource::decRef();
-}
-#endif // USE_OPENGL
-
-int SubImage::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(SubImage) +
- sizeof(std::map<float, SDL_Surface*>)) +
- Resource::calcMemoryLocal();
-}
diff --git a/src/resources/image/subimage.h b/src/resources/image/subimage.h
deleted file mode 100644
index 6f0b2e11b..000000000
--- a/src/resources/image/subimage.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SUBIMAGE_H
-#define RESOURCES_SUBIMAGE_H
-
-#include "localconsts.h"
-
-#include "resources/image/image.h"
-
-/**
- * A clipped version of a larger image.
- */
-class SubImage final : public Image
-{
- public:
- /**
- * Constructor.
- */
-#ifdef USE_SDL2
- SubImage(Image *const parent, SDL_Texture *const image,
- const int x, const int y, const int width, const int height);
-#endif // USE_SDL2
-
- SubImage(Image *const parent, SDL_Surface *const image,
- const int x, const int y, const int width, const int height);
-#ifdef USE_OPENGL
- SubImage(Image *const parent, const GLuint image,
- const int x, const int y, const int width, const int height,
- const int texWidth, const int textHeight);
-#endif // USE_OPENGL
-
- A_DELETE_COPY(SubImage)
-
- /**
- * Destructor.
- */
- ~SubImage();
-
- /**
- * Creates a new image with the desired clipping rectangle.
- *
- * @return <code>NULL</code> if creation failed and a valid
- * image otherwise.
- */
- Image *getSubImage(const int x, const int y,
- const int width,
- const int height) override final A_WARN_UNUSED;
-
- ImageTypeT getType() const noexcept2 override final
- { return ImageType::SubImage; }
-
- int calcMemoryLocal() const override;
-
-#ifdef USE_OPENGL
- void decRef() override final;
-#endif // USE_OPENGL
-
- SDL_Rect mInternalBounds;
-
- private:
- Image *mParent;
-};
-
-#endif // RESOURCES_SUBIMAGE_H
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp
deleted file mode 100644
index 76747979b..000000000
--- a/src/resources/imagehelper.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/imagehelper.h"
-
-#include "logger.h"
-
-#include "resources/dye/dye.h"
-#include "resources/dye/dyepalette.h"
-
-#include "utils/sdlcheckutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-ImageHelper *imageHelper = nullptr;
-ImageHelper *surfaceImageHelper = nullptr;
-
-bool ImageHelper::mEnableAlpha = true;
-RenderType ImageHelper::mUseOpenGL = RENDER_SOFTWARE;
-
-Image *ImageHelper::load(SDL_RWops *const rw)
-{
- SDL_Surface *const tmpImage = loadPng(rw);
- if (tmpImage == nullptr)
- {
- logger->log("Error, image load failed: %s", SDL_GetError());
- return nullptr;
- }
-
- Image *const image = loadSurface(tmpImage);
-
- MSDL_FreeSurface(tmpImage);
- return image;
-}
-
-Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye)
-{
- BLOCK_START("ImageHelper::load")
- SDL_Surface *const tmpImage = loadPng(rw);
- if (tmpImage == nullptr)
- {
- logger->log("Error, image load failed: %s", SDL_GetError());
- BLOCK_END("ImageHelper::load")
- return nullptr;
- }
-
- SDL_PixelFormat rgba;
- rgba.palette = nullptr;
- rgba.BitsPerPixel = 32;
- rgba.BytesPerPixel = 4;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rgba.Rmask = 0x000000FF;
- rgba.Gmask = 0x0000FF00;
- rgba.Bmask = 0x00FF0000;
- rgba.Amask = 0xFF000000;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- rgba.Rmask = 0xFF000000;
- rgba.Gmask = 0x00FF0000;
- rgba.Bmask = 0x0000FF00;
- rgba.Amask = 0x000000FF;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- SDL_Surface *const surf = MSDL_ConvertSurface(
- tmpImage, &rgba, SDL_SWSURFACE);
- MSDL_FreeSurface(tmpImage);
-
- if (surf == nullptr)
- return nullptr;
-
- uint32_t *const pixels = static_cast<uint32_t *>(surf->pixels);
- const int type = dye.getType();
-
- switch (type)
- {
- case 1:
- {
- const DyePalette *const pal = dye.getSPalete();
- if (pal != nullptr)
- DYEPALETTEP(pal, SColor)(pixels, surf->w * surf->h);
- break;
- }
- case 2:
- {
- const DyePalette *const pal = dye.getAPalete();
- if (pal != nullptr)
- DYEPALETTEP(pal, AColor)(pixels, surf->w * surf->h);
- break;
- }
- case 0:
- default:
- {
- dye.normalDye(pixels, surf->w * surf->h);
- break;
- }
- }
-
- Image *const image = loadSurface(surf);
- MSDL_FreeSurface(surf);
- BLOCK_END("ImageHelper::load")
- return image;
-}
-
-SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage)
-{
- if (tmpImage == nullptr)
- return nullptr;
- SDL_PixelFormat RGBAFormat;
- RGBAFormat.palette = nullptr;
-#ifndef USE_SDL2
- RGBAFormat.colorkey = 0;
- RGBAFormat.alpha = 0;
-#endif // USE_SDL2
-
- RGBAFormat.BitsPerPixel = 32;
- RGBAFormat.BytesPerPixel = 4;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- RGBAFormat.Rmask = 0xFF000000;
- RGBAFormat.Rshift = 0;
- RGBAFormat.Rloss = 0;
- RGBAFormat.Gmask = 0x00FF0000;
- RGBAFormat.Gshift = 8;
- RGBAFormat.Gloss = 0;
- RGBAFormat.Bmask = 0x0000FF00;
- RGBAFormat.Bshift = 16;
- RGBAFormat.Bloss = 0;
- RGBAFormat.Amask = 0x000000FF;
- RGBAFormat.Ashift = 24;
- RGBAFormat.Aloss = 0;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- RGBAFormat.Rmask = 0x000000FF;
- RGBAFormat.Rshift = 24;
- RGBAFormat.Rloss = 0;
- RGBAFormat.Gmask = 0x0000FF00;
- RGBAFormat.Gshift = 16;
- RGBAFormat.Gloss = 0;
- RGBAFormat.Bmask = 0x00FF0000;
- RGBAFormat.Bshift = 8;
- RGBAFormat.Bloss = 0;
- RGBAFormat.Amask = 0xFF000000;
- RGBAFormat.Ashift = 0;
- RGBAFormat.Aloss = 0;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- return MSDL_ConvertSurface(tmpImage, &RGBAFormat, SDL_SWSURFACE);
-}
-
-void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image)
-{
- if (image == nullptr)
- return;
- if (image->format != nullptr)
- {
- const SDL_PixelFormat * const format = image->format;
- logger->log("Bytes per pixel: %d", format->BytesPerPixel);
-#ifdef USE_SDL2
- logger->log("Format: %u", format->format);
-#else // USE_SDL2
-
- logger->log("Alpha: %d", format->alpha);
- logger->log("Color key: %u", format->colorkey);
-#endif // USE_SDL2
-
- logger->log("Loss: %02x, %02x, %02x, %02x",
- CAST_U32(format->Rloss),
- CAST_U32(format->Gloss),
- CAST_U32(format->Bloss),
- CAST_U32(format->Aloss));
- logger->log("Shift: %02x, %02x, %02x, %02x",
- CAST_U32(format->Rshift),
- CAST_U32(format->Gshift),
- CAST_U32(format->Bshift),
- CAST_U32(format->Ashift));
- logger->log("Mask: %08x, %08x, %08x, %08x", format->Rmask,
- format->Gmask, format->Bmask, format->Amask);
- }
- logger->log("Flags: %u", image->flags);
- logger->log("Pitch: %d", CAST_S32(image->pitch));
-#ifndef USE_SDL2
- logger->log("Offset: %d", image->offset);
-#endif // USE_SDL2
-}
-
-SDL_Surface *ImageHelper::loadPng(SDL_RWops *const rw)
-{
- if (rw == nullptr)
- return nullptr;
-
- if (IMG_isPNG(rw) != 0)
- {
- SDL_Surface *const tmpImage = MIMG_LoadPNG_RW(rw);
- SDL_RWclose(rw);
- return tmpImage;
- }
-
- if (IMG_isJPG(rw) != 0)
- {
- SDL_Surface *const tmpImage = MIMG_LoadJPG_RW(rw);
- SDL_RWclose(rw);
- return tmpImage;
- }
-
- logger->log("Error, image is not png");
- SDL_RWclose(rw);
- return nullptr;
-}
-
-SDL_Surface *ImageHelper::create32BitSurface(int width,
- int height) const
-{
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
- const int amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
- const int amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- return MSDL_CreateRGBSurface(SDL_SWSURFACE,
- width, height, 32, rmask, gmask, bmask, amask);
-}
diff --git a/src/resources/imagehelper.h b/src/resources/imagehelper.h
deleted file mode 100644
index facd29d18..000000000
--- a/src/resources/imagehelper.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_IMAGEHELPER_H
-#define RESOURCES_IMAGEHELPER_H
-
-#include "localconsts.h"
-
-#include "enums/render/rendertype.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_video.h>
-PRAGMA48(GCC diagnostic pop)
-
-class Dye;
-class Image;
-
-/**
- * Defines a class for loading and storing images.
- */
-class ImageHelper notfinal
-{
- friend class CompoundSprite;
- friend class Image;
-
- public:
- A_DELETE_COPY(ImageHelper)
-
- virtual ~ImageHelper()
- { }
-
- /**
- * Loads an image from an SDL_RWops structure.
- *
- * @param rw The SDL_RWops to load the image from.
- *
- * @return <code>NULL</code> if an error occurred, a valid pointer
- * otherwise.
- */
- Image *load(SDL_RWops *const rw) A_WARN_UNUSED;
-
- virtual Image *load(SDL_RWops *const rw, Dye const &dye) A_WARN_UNUSED;
-
-#ifdef __GNUC__
- virtual Image *loadSurface(SDL_Surface *const) A_WARN_UNUSED = 0;
-
- virtual Image *createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- float alpha) A_WARN_UNUSED = 0;
-#else // __GNUC__
-
- virtual Image *loadSurface(SDL_Surface *const) A_WARN_UNUSED
- { return nullptr; }
-
- virtual Image *createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- const float alpha) const A_WARN_UNUSED
- { return nullptr; }
-#endif // __GNUC__
-
- virtual SDL_Surface *create32BitSurface(int width,
- int height)
- const A_WARN_UNUSED;
-
- virtual void copySurfaceToImage(const Image *const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- SDL_Surface *const surface A_UNUSED)
- const
- { }
-
- static SDL_Surface *convertTo32Bit(SDL_Surface *const tmpImage)
- A_WARN_UNUSED;
-
- static void dumpSurfaceFormat(const SDL_Surface *const image);
-
- constexpr2 static void setEnableAlpha(const bool n) noexcept2
- { mEnableAlpha = n; }
-
- static SDL_Surface *loadPng(SDL_RWops *const rw);
-
- constexpr2 static void setOpenGlMode(const RenderType useOpenGL)
- noexcept2
- { mUseOpenGL = useOpenGL; }
-
- virtual RenderType useOpenGL() const noexcept2 A_WARN_UNUSED
- { return mUseOpenGL; }
-
- virtual void postInit()
- { }
-
- protected:
- ImageHelper()
- { }
-
- static bool mEnableAlpha;
- static RenderType mUseOpenGL;
-};
-
-extern ImageHelper *imageHelper A_NONNULLPOINTER;
-extern ImageHelper *surfaceImageHelper A_NONNULLPOINTER;
-#endif // RESOURCES_IMAGEHELPER_H
diff --git a/src/resources/imagerect.h b/src/resources/imagerect.h
deleted file mode 100644
index 003f2b540..000000000
--- a/src/resources/imagerect.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_IMAGERECT_H
-#define RESOURCES_IMAGERECT_H
-
-#include "localconsts.h"
-
-class Image;
-
-class ImageRect final
-{
- public:
- ImageRect()
- {
- for (int f = 0; f < 9; f ++)
- grid[f] = nullptr;
- }
-
- A_DELETE_COPY(ImageRect)
-
- Image *grid[9] A_NONNULLPOINTER;
-};
-
-#endif // RESOURCES_IMAGERECT_H
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
deleted file mode 100644
index 724038100..000000000
--- a/src/resources/imageset.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/imageset.h"
-
-#include "logger.h"
-
-#include "resources/image/image.h"
-
-#include "utils/cast.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-ImageSet::ImageSet(Image *const img, const int width, const int height,
- const int margin, const int spacing) :
- Resource(),
- mImages(),
- mWidth(width),
- mHeight(height),
- mOffsetX(0),
- mOffsetY(0)
-{
- if (img != nullptr)
- {
- const int hAdd = height + spacing;
- const int wAdd = width + spacing;
- for (int y = margin; y + height <= img->getHeight() - margin;
- y += hAdd)
- {
- for (int x = margin; x + width <= img->getWidth() - margin;
- x += wAdd)
- {
- Image *const image = img->getSubImage(x, y, width, height);
- image->mNotCount = true;
- mImages.push_back(image);
- }
- }
- }
-}
-
-ImageSet::~ImageSet()
-{
- delete_all(mImages);
-}
-
-Image* ImageSet::get(const size_type i) const
-{
- if (i >= mImages.size())
- {
- logger->log("Warning: No sprite %d in this image set",
- CAST_S32(i));
- return nullptr;
- }
- return mImages[i];
-}
-
-int ImageSet::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(ImageSet)) +
- Resource::calcMemoryLocal() +
- static_cast<int>(mImages.capacity() * sizeof(Image));
-}
diff --git a/src/resources/imageset.h b/src/resources/imageset.h
deleted file mode 100644
index 78907fbba..000000000
--- a/src/resources/imageset.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_IMAGESET_H
-#define RESOURCES_IMAGESET_H
-
-#include "resources/resource.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class Image;
-
-/**
- * Stores a set of subimages originating from a single image.
- */
-class ImageSet notfinal : public Resource
-{
- public:
- /**
- * Cuts the passed image in a grid of sub images.
- */
- ImageSet(Image *const img, const int w, const int h,
- const int margin = 0, const int spacing = 0);
-
- A_DELETE_COPY(ImageSet)
-
- /**
- * Destructor.
- */
- virtual ~ImageSet();
-
- /**
- * Returns the width of the images in the image set.
- */
- int getWidth() const noexcept2 A_WARN_UNUSED
- { return mWidth; }
-
- /**
- * Returns the height of the images in the image set.
- */
- int getHeight() const noexcept2 A_WARN_UNUSED
- { return mHeight; }
-
- typedef STD_VECTOR<Image*>::size_type size_type;
-
- Image* get(const size_type i) const A_WARN_UNUSED;
-
- size_type size() const noexcept2 A_WARN_UNUSED
- { return mImages.size(); }
-
- int getOffsetX() const noexcept2 A_WARN_UNUSED
- { return mOffsetX; }
-
- void setOffsetX(const int n) noexcept2
- { mOffsetX = n; }
-
- int getOffsetY() const noexcept2 A_WARN_UNUSED
- { return mOffsetY; }
-
- void setOffsetY(const int n) noexcept2
- { mOffsetY = n; }
-
- const STD_VECTOR<Image*> &getImages() const noexcept2 A_WARN_UNUSED
- { return mImages; }
-
- int calcMemoryLocal() const override;
-
- private:
- STD_VECTOR<Image*> mImages;
-
- int mWidth; /**< Width of the images in the image set. */
- int mHeight; /**< Height of the images in the image set. */
- int mOffsetX;
- int mOffsetY;
-};
-
-#endif // RESOURCES_IMAGESET_H
diff --git a/src/resources/inventory/complexinventory.cpp b/src/resources/inventory/complexinventory.cpp
deleted file mode 100644
index c6037fe38..000000000
--- a/src/resources/inventory/complexinventory.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/inventory/complexinventory.h"
-
-#include "logger.h"
-
-#include "being/playerinfo.h"
-
-#include "utils/cast.h"
-
-#include "resources/item/complexitem.h"
-
-#include "debug.h"
-
-ComplexInventory::ComplexInventory(const InventoryTypeT type,
- const int size1) :
- Inventory(type, size1)
-{
-}
-
-ComplexInventory::~ComplexInventory()
-{
-}
-
-bool ComplexInventory::addVirtualItem(const Item *const item,
- int index,
- const int amount)
-{
- if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
- return false;
-
- if (index >= 0 && index < CAST_S32(mSize))
- {
- ComplexItem *citem = nullptr;
- if (mItems[index] != nullptr)
- {
- const Item *const item2 = mItems[index];
- if (item->getId() != item2->getId() ||
- item->getColor() != item2->getColor())
- { // not same id or color
- return false;
- }
- citem = dynamic_cast<ComplexItem*>(mItems[index]);
- if (citem == nullptr)
- { // if in inventory not complex item, converting it to complex
- citem = new ComplexItem(item2->getId(),
- item2->getType(),
- item2->getQuantity(),
- item2->getRefine(),
- item2->getColor(),
- item2->getIdentified(),
- item2->getDamaged(),
- item2->getFavorite(),
- Equipm_false,
- Equipped_false);
- citem->setTag(item2->getTag());
- delete mItems[index];
- mItems[index] = citem;
- }
- }
- else
- {
- citem = new ComplexItem(item->getId(),
- item->getType(),
- 0,
- item->getRefine(),
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- Equipm_false,
- Equipped_false);
- mItems[index] = citem;
- }
- citem->addChild(item, amount);
- }
- else
- {
- index = addItem(item->getId(),
- item->getType(),
- 1,
- 1,
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- Equipm_false,
- Equipped_false);
- }
- if (index == -1)
- return false;
-
- Item *const item2 = getItem(index);
- if (item2 != nullptr)
- item2->setTag(item->getInvIndex());
- return true;
-}
-
-void ComplexInventory::setItem(const int index,
- const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped)
-{
- if (index < 0 || index >= CAST_S32(mSize))
- {
- logger->log("Warning: invalid inventory index: %d", index);
- return;
- }
-
- const Item *const item1 = mItems[index];
- if ((item1 == nullptr) && id > 0)
- {
- ComplexItem *const item = new ComplexItem(id,
- type,
- quantity,
- refine,
- color,
- identified,
- damaged,
- favorite,
- equipment,
- equipped);
- item->setInvIndex(index);
-
- Item *const item2 = new Item(id,
- type,
- quantity,
- refine,
- color,
- identified,
- damaged,
- favorite,
- equipment,
- equipped);
- item2->setInvIndex(index);
- item->addChild(item2, quantity);
- delete item2;
-
- mItems[index] = item;
- mUsed ++;
- distributeSlotsChangedEvent();
- }
-}
diff --git a/src/resources/inventory/complexinventory.h b/src/resources/inventory/complexinventory.h
deleted file mode 100644
index f016ab5e5..000000000
--- a/src/resources/inventory/complexinventory.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_INVENTORY_COMPLEXINVENTORY_H
-#define RESOURCES_INVENTORY_COMPLEXINVENTORY_H
-
-#include "resources/inventory/inventory.h"
-
-#include "localconsts.h"
-
-class ComplexInventory final : public Inventory
-{
- public:
- A_DELETE_COPY(ComplexInventory)
-
- /**
- * Constructor.
- *
- * @param size the number of items that fit in the inventory
- */
- explicit ComplexInventory(const InventoryTypeT type,
- const int size = -1);
-
- /**
- * Destructor.
- */
- ~ComplexInventory();
-
- bool addVirtualItem(const Item *const item,
- int index,
- const int amount) override final;
-
- void setItem(const int index,
- const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped) override final;
-};
-
-#endif // RESOURCES_INVENTORY_COMPLEXINVENTORY_H
diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp
deleted file mode 100644
index d256ea9ac..000000000
--- a/src/resources/inventory/inventory.cpp
+++ /dev/null
@@ -1,556 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/inventory/inventory.h"
-
-#include "being/playerinfo.h"
-
-#include "net/inventoryhandler.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/item/item.h"
-
-#include "listeners/inventorylistener.h"
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-namespace
-{
- struct SlotUsed final
- {
- A_DEFAULT_COPY(SlotUsed)
-
- bool operator()(const Item *const item) const
- {
- return (item != nullptr) && item->mId >= 0 && item->mQuantity > 0;
- }
- typedef Item *argument_type;
- };
-} // namespace
-
-Inventory::Inventory(const InventoryTypeT type,
- const int size1) :
- mInventoryListeners(),
- mVirtualRemove(),
- mType(type),
- mSize(size1 == -1 ? CAST_U32(
- inventoryHandler->getSize(type))
- : CAST_U32(size1)),
- mItems(new Item*[mSize]),
- mUsed(0)
-{
- std::fill_n(mItems, mSize, static_cast<Item*>(nullptr));
-}
-
-Inventory::~Inventory()
-{
- for (unsigned i = 0; i < mSize; i++)
- delete mItems[i];
-
- delete [] mItems;
- mItems = nullptr;
-}
-
-Item *Inventory::getItem(const int index) const
-{
- if (index < 0 || index >= CAST_S32(mSize) || (mItems[index] == nullptr)
- || mItems[index]->mQuantity <= 0)
- {
- return nullptr;
- }
-
- return mItems[index];
-}
-
-Item *Inventory::findItem(const int itemId,
- const ItemColor color) const
-{
- for (unsigned i = 0; i < mSize; i++)
- {
- Item *const item = mItems[i];
- if ((item != nullptr) && item->mId == itemId)
- {
- if (color == ItemColor_zero ||
- item->mColor == color ||
- (color == ItemColor_one &&
- item->mColor <= ItemColor_one))
- {
- return item;
- }
- }
- }
-
- return nullptr;
-}
-
-int Inventory::addItem(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped)
-{
- const int slot = getFreeSlot();
- setItem(slot,
- id,
- type,
- quantity,
- refine,
- color,
- identified,
- damaged,
- favorite,
- equipment,
- equipped);
- return slot;
-}
-
-void Inventory::setItem(const int index,
- const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped)
-{
- if (index < 0 || index >= CAST_S32(mSize))
- {
- reportAlways("Warning: invalid inventory index: %d",
- index);
- return;
- }
-
- Item *const item1 = mItems[index];
- if ((item1 == nullptr) && id > 0)
- {
- Item *const item = new Item(id,
- type,
- quantity,
- refine,
- color,
- identified,
- damaged,
- favorite,
- equipment,
- equipped);
- item->setInvIndex(index);
- mItems[index] = item;
- mUsed++;
- distributeSlotsChangedEvent();
- }
- else if (id > 0 && (item1 != nullptr))
- {
- item1->setId(id, color);
- item1->setQuantity(quantity);
- item1->setRefine(refine);
- item1->setEquipment(equipment);
- item1->setIdentified(identified);
- item1->setDamaged(damaged);
- item1->setFavorite(favorite);
- }
- else if (item1 != nullptr)
- {
- removeItemAt(index);
- }
-}
-
-void Inventory::setCards(const int index,
- const int *const cards,
- const int size) const
-{
- if (index < 0 || index >= CAST_S32(mSize))
- {
- reportAlways("Warning: invalid inventory index: %d",
- index);
- return;
- }
-
- Item *const item1 = mItems[index];
- if (item1 != nullptr)
- item1->setCards(cards, size);
-}
-
-void Inventory::setOptions(const int index,
- const ItemOptionsList *const options)
-{
- if (index < 0 || index >= CAST_S32(mSize))
- {
- reportAlways("Warning: invalid inventory index: %d",
- index);
- return;
- }
- Item *const item1 = mItems[index];
- if (item1 != nullptr)
- item1->setOptions(options);
-}
-
-void Inventory::setTag(const int index,
- const int tag)
-{
- if (index < 0 || index >= CAST_S32(mSize))
- {
- reportAlways("Warning: invalid inventory index: %d",
- index);
- return;
- }
- Item *const item1 = mItems[index];
- if (item1 != nullptr)
- item1->setTag(tag);
-}
-
-void Inventory::clear()
-{
- for (unsigned i = 0; i < mSize; i++)
- removeItemAt(i);
-}
-
-void Inventory::removeItem(const int id)
-{
- for (unsigned i = 0; i < mSize; i++)
- {
- const Item *const item = mItems[i];
- if ((item != nullptr) && item->mId == id)
- removeItemAt(i);
- }
-}
-
-void Inventory::removeItemAt(const int index)
-{
- if (mItems[index] == nullptr)
- return;
- delete2(mItems[index]);
- mUsed--;
- if (mUsed < 0) // Already at 0, no need to distribute event
- mUsed = 0;
- else
- distributeSlotsChangedEvent();
-}
-
-bool Inventory::contains(const Item *const item) const
-{
- if (item == nullptr)
- return false;
-
- const int id = item->mId;
- for (unsigned i = 0; i < mSize; i++)
- {
- const Item *const item1 = mItems[i];
- if ((item1 != nullptr) && item1->mId == id)
- return true;
- }
-
- return false;
-}
-
-int Inventory::getFreeSlot() const
-{
- Item *const *const i = std::find_if(mItems,
- mItems + mSize,
- std::not1(SlotUsed()));
- return (i == mItems + mSize) ? -1
- : CAST_S32(i - mItems);
-}
-
-int Inventory::getLastUsedSlot() const
-{
- for (int i = mSize - 1; i >= 0; i--)
- {
- if (SlotUsed()(mItems[i]))
- return i;
- }
-
- return -1;
-}
-
-void Inventory::addInventoyListener(InventoryListener* const listener)
-{
- mInventoryListeners.push_back(listener);
-}
-
-void Inventory::removeInventoyListener(InventoryListener* const listener)
-{
- mInventoryListeners.remove(listener);
-}
-
-void Inventory::distributeSlotsChangedEvent()
-{
- FOR_EACH (InventoryListenerList::const_iterator, i, mInventoryListeners)
- (*i)->slotsChanged(this);
-}
-
-const Item *Inventory::findItemBySprite(std::string spritePath,
- const GenderT gender,
- const BeingTypeId race) const
-{
- spritePath = removeSpriteIndex(spritePath);
-
- const std::string spritePathShort = extractNameFromSprite(spritePath);
- int partialIndex = -1;
-
- for (unsigned i = 0; i < mSize; i++)
- {
- const Item *const item = mItems[i];
- if (item != nullptr)
- {
- std::string path = item->getInfo().getSprite(gender, race);
- if (!path.empty())
- {
- path = removeSpriteIndex(path);
- if (spritePath == path)
- return item;
-
- path = extractNameFromSprite(path);
- if (spritePathShort == path)
- partialIndex = i;
- }
- }
- }
- if (partialIndex != -1)
- return mItems[partialIndex];
-
- return nullptr;
-}
-
-std::string Inventory::getName() const
-{
- switch (mType)
- {
- case InventoryType::Inventory:
- case InventoryType::Vending:
- case InventoryType::TypeEnd:
- default:
- {
- // TRANSLATORS: inventory type name
- return N_("Inventory");
- }
- case InventoryType::Storage:
- {
- // TRANSLATORS: inventory type name
- return N_("Storage");
- }
- case InventoryType::Npc:
- {
- // TRANSLATORS: inventory type name
- return N_("Npc");
- }
- case InventoryType::Cart:
- {
- // TRANSLATORS: inventory type name
- return N_("Cart");
- }
- case InventoryType::MailEdit:
- case InventoryType::MailView:
- {
- // TRANSLATORS: inventory type name
- return N_("Mail");
- }
- case InventoryType::Craft:
- {
- // TRANSLATORS: inventory type name
- return N_("Craft");
- }
- case InventoryType::Trade:
- {
- // TRANSLATORS: inventory type name
- return N_("Trade");
- }
- }
-}
-
-void Inventory::resize(const unsigned int newSize)
-{
- clear();
- if (mSize == newSize)
- return;
-
- for (unsigned i = 0; i < mSize; i++)
- delete mItems[i];
- delete [] mItems;
-
- mSize = newSize;
- mItems = new Item*[CAST_SIZE(mSize)];
- std::fill_n(mItems, mSize, static_cast<Item*>(nullptr));
-}
-
-int Inventory::findIndexByTag(const int tag) const
-{
- for (unsigned i = 0; i < mSize; i++)
- {
- const Item *const item = mItems[i];
- if ((item != nullptr) && item->mTag == tag)
- return i;
- }
-
- return -1;
-}
-
-Item *Inventory::findItemByTag(const int tag) const
-{
- for (unsigned i = 0; i < mSize; i++)
- {
- Item *const item = mItems[i];
- if (item != nullptr &&
- item->mTag == tag)
- {
- return item;
- }
- }
-
- return nullptr;
-}
-
-bool Inventory::addVirtualItem(const Item *const item,
- int index,
- const int amount)
-{
- if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
- {
- if (index >= 0 && index < CAST_S32(mSize))
- {
- if (mItems[index] != nullptr)
- return false;
- setItem(index,
- item->getId(),
- item->getType(),
- amount,
- 1,
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- Equipm_false,
- Equipped_false);
- }
- else
- {
- index = addItem(item->getId(),
- item->getType(),
- amount,
- 1,
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- Equipm_false,
- Equipped_false);
- }
- if (index == -1)
- return false;
-
- Item *const item2 = getItem(index);
- if (item2 != nullptr)
- item2->setTag(item->getInvIndex());
- return true;
- }
- return false;
-}
-
-void Inventory::virtualRemove(Item *const item,
- const int amount)
-{
- if ((item == nullptr) || item->mQuantity < amount)
- return;
-
- const int index = item->getInvIndex();
- const IntMapCIter it = mVirtualRemove.find(index);
- if (it == mVirtualRemove.end())
- mVirtualRemove[index] = amount;
- else
- mVirtualRemove[index] += amount;
- item->mQuantity -= amount;
-}
-
-void Inventory::restoreVirtuals()
-{
- const int sz = CAST_S32(mSize);
-
- FOR_EACH (IntMapCIter, it, mVirtualRemove)
- {
- const int index = (*it).first;
- if (index < 0 || index >= sz)
- continue;
- Item *const item = mItems[index];
- if (item == nullptr)
- continue;
- item->mQuantity += (*it).second;
- }
- mVirtualRemove.clear();
-}
-
-void Inventory::virtualRestore(const Item *const item,
- const int amount)
-{
- const int index = item->getTag();
- const IntMapCIter it = mVirtualRemove.find(index);
- if (it != mVirtualRemove.end())
- {
- mVirtualRemove[index] -= amount;
- if (mVirtualRemove[index] < 0)
- mVirtualRemove.erase(index);
- if (index < 0 ||
- index >= CAST_S32(mSize) ||
- mItems[index] == nullptr)
- {
- return;
- }
- mItems[index]->mQuantity += amount;
- }
-}
-
-void Inventory::moveItem(const int index1,
- const int index2)
-{
- if (index1 < 0 ||
- index1 >= CAST_S32(mSize) ||
- index2 < 0 ||
- index2 >= CAST_S32(mSize))
- {
- return;
- }
-
- Item *const item1 = mItems[index1];
- Item *const item2 = mItems[index2];
- if (item1 != nullptr)
- item1->setInvIndex(index2);
- if (item2 != nullptr)
- item2->setInvIndex(index1);
- mItems[index1] = item2;
- mItems[index2] = item1;
- distributeSlotsChangedEvent();
-}
diff --git a/src/resources/inventory/inventory.h b/src/resources/inventory/inventory.h
deleted file mode 100644
index 573a0f5c0..000000000
--- a/src/resources/inventory/inventory.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_INVENTORY_INVENTORY_H
-#define RESOURCES_INVENTORY_INVENTORY_H
-
-#include "enums/inventorytype.h"
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/damaged.h"
-#include "enums/simpletypes/equipm.h"
-#include "enums/simpletypes/equipped.h"
-#include "enums/simpletypes/favorite.h"
-#include "enums/simpletypes/identified.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "enums/being/gender.h"
-
-#include "utils/intmap.h"
-
-#include <list>
-#include <string>
-
-#include "localconsts.h"
-
-class InventoryListener;
-class Item;
-
-struct ItemOptionsList;
-
-class Inventory notfinal
-{
- public:
- A_DELETE_COPY(Inventory)
-
- static const int NO_SLOT_INDEX = -1; /**< Slot has no index. */
-
- /**
- * Constructor.
- *
- * @param size the number of items that fit in the inventory
- */
- explicit Inventory(const InventoryTypeT type,
- const int size = -1);
-
- /**
- * Destructor.
- */
- virtual ~Inventory();
-
- /**
- * Returns the size that this instance is configured for.
- */
- unsigned getSize() const noexcept2 A_WARN_UNUSED
- { return mSize; }
-
- /**
- * Returns the item at the specified index.
- */
- Item *getItem(const int index) const A_WARN_UNUSED;
-
- /**
- * Searches for the specified item by it's id.
- *
- * @param itemId The id of the item to be searched.
- * @param color The color of the item to be searched.
- * @return Item found on success, NULL on failure.
- */
- Item *findItem(const int itemId,
- const ItemColor color) const A_WARN_UNUSED;
-
- /**
- * Adds a new item in a free slot.
- */
- int addItem(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped);
-
- /**
- * Sets the item at the given position.
- */
- virtual void setItem(const int index,
- const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped);
-
- void setCards(const int index,
- const int *const cards,
- const int size) const;
-
- void setOptions(const int index,
- const ItemOptionsList *const options);
-
- void setTag(const int index,
- const int tag);
-
- void moveItem(const int index1,
- const int index2);
-
- /**
- * Remove a item from the inventory.
- */
- void removeItem(const int id);
-
- /**
- * Remove the item at the specified index from the inventory.
- */
- void removeItemAt(const int index);
-
- /**
- * Checks if the given item is in the inventory.
- */
- bool contains(const Item *const item) const A_WARN_UNUSED;
-
- /**
- * Returns id of next free slot or -1 if all occupied.
- */
- int getFreeSlot() const A_WARN_UNUSED;
-
- /**
- * Reset all item slots.
- */
- void clear();
-
- /**
- * Get the number of slots filled with an item
- */
- int getNumberOfSlotsUsed() const noexcept2 A_WARN_UNUSED
- { return mUsed; }
-
- /**
- * Returns the index of the last occupied slot or 0 if none occupied.
- */
- int getLastUsedSlot() const A_WARN_UNUSED;
-
- void addInventoyListener(InventoryListener *const listener);
-
- void removeInventoyListener(InventoryListener *const listener);
-
- InventoryTypeT getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- bool isMainInventory() const noexcept2 A_WARN_UNUSED
- { return mType == InventoryType::Inventory; }
-
- const Item *findItemBySprite(std::string spritePath,
- const GenderT gender,
- const BeingTypeId race)
- const A_WARN_UNUSED;
-
- std::string getName() const A_WARN_UNUSED;
-
- void resize(const unsigned int newSize);
-
- int findIndexByTag(const int tag) const;
-
- Item *findItemByTag(const int tag) const;
-
- virtual bool addVirtualItem(const Item *const item,
- int index,
- const int amount);
-
- void virtualRemove(Item *const item,
- const int amount);
-
- void virtualRestore(const Item *const item,
- const int amount);
-
- void restoreVirtuals();
-
- protected:
- typedef std::list<InventoryListener*> InventoryListenerList;
- InventoryListenerList mInventoryListeners;
-
- void distributeSlotsChangedEvent();
-
- IntMap mVirtualRemove;
- InventoryTypeT mType;
- unsigned mSize; /**< The max number of inventory items */
- Item **mItems; /**< The holder of items */
- int mUsed; /**< THe number of slots in use */
-};
-
-#endif // RESOURCES_INVENTORY_INVENTORY_H
diff --git a/src/resources/item/cardslist.cpp b/src/resources/item/cardslist.cpp
deleted file mode 100644
index d4e26466f..000000000
--- a/src/resources/item/cardslist.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/item/cardslist.h"
-
-#include "debug.h"
-
-CardsList zeroCards(0, 0, 0, 0);
diff --git a/src/resources/item/cardslist.h b/src/resources/item/cardslist.h
deleted file mode 100644
index 6bc1f5e22..000000000
--- a/src/resources/item/cardslist.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_CARDSLIST_H
-#define RESOURCES_ITEM_CARDSLIST_H
-
-#include "const/resources/item/cards.h"
-
-#include "localconsts.h"
-
-struct CardsList final
-{
- CardsList(const int card0,
- const int card1,
- const int card2,
- const int card3)
- {
- cards[0] = card0;
- cards[1] = card1;
- cards[2] = card2;
- cards[3] = card3;
- }
-
- explicit CardsList(const int *const cards0)
- {
- if (cards0 != nullptr)
- {
- for (int f = 0; f < maxCards; f ++)
- cards[f] = cards0[f];
- }
- else
- {
- for (int f = 0; f < maxCards; f ++)
- cards[f] = 0;
- }
- }
-
- A_DEFAULT_COPY(CardsList)
-
- bool isEmpty() const noexcept2 A_WARN_UNUSED
- {
- return cards[0] == 0 &&
- cards[1] == 0 &&
- cards[2] == 0 &&
- cards[3] == 0;
- }
-
- int cards[maxCards];
-};
-
-extern CardsList zeroCards;
-
-#endif // RESOURCES_ITEM_CARDSLIST_H
diff --git a/src/resources/item/complexitem.cpp b/src/resources/item/complexitem.cpp
deleted file mode 100644
index 1fd703f8c..000000000
--- a/src/resources/item/complexitem.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/item/complexitem.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-ComplexItem::ComplexItem(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped) :
- Item(id,
- type,
- quantity,
- refine,
- color,
- identified,
- damaged,
- favorite,
- equipment,
- equipped),
- mChildItems()
-{
-}
-
-ComplexItem::~ComplexItem()
-{
- delete_all(mChildItems);
- mChildItems.clear();
-}
-
-void ComplexItem::addChild(const Item *const item,
- const int amount)
-{
- if (item == nullptr)
- return;
- increaseQuantity(amount);
- Item *child = nullptr;
- FOR_EACH (STD_VECTOR<Item*>::iterator, it, mChildItems)
- {
- Item *const item1 = *it;
- if (item1->getId() == item->getId() &&
- item1->getInvIndex() == item->getInvIndex() &&
- item1->getTag() == item->getTag())
- {
- child = item1;
- break;
- }
- }
- if (child != nullptr)
- {
- child->increaseQuantity(amount);
- }
- else
- {
- child = new ComplexItem(item->getId(),
- item->getType(),
- amount,
- item->getRefine(),
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- Equipm_false,
- Equipped_false);
- child->setTag(item->getTag());
- child->setInvIndex(item->getInvIndex());
- mChildItems.push_back(child);
- }
-}
diff --git a/src/resources/item/complexitem.h b/src/resources/item/complexitem.h
deleted file mode 100644
index aa41fb3fd..000000000
--- a/src/resources/item/complexitem.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_COMPLEXITEM_H
-#define RESOURCES_ITEM_COMPLEXITEM_H
-
-#include "resources/item/item.h"
-
-#include "localconsts.h"
-
-/**
- * Represents one or more instances of a certain item type.
- */
-class ComplexItem final : public Item
-{
- public:
- /**
- * Constructor.
- */
- ComplexItem(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped);
-
- A_DELETE_COPY(ComplexItem)
-
- /**
- * Destructor.
- */
- virtual ~ComplexItem();
-
- void addChild(const Item *const item,
- const int amount);
-
- const STD_VECTOR<Item*> &getChilds() const noexcept2 A_WARN_UNUSED
- { return mChildItems; }
-
- protected:
- STD_VECTOR<Item*> mChildItems;
-};
-
-#endif // RESOURCES_ITEM_COMPLEXITEM_H
diff --git a/src/resources/item/item.cpp b/src/resources/item/item.cpp
deleted file mode 100644
index a9a2c89df..000000000
--- a/src/resources/item/item.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/item/item.h"
-
-#include "configuration.h"
-#include "dragdrop.h"
-#include "itemcolormanager.h"
-
-#include "gui/theme.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/item/itemoptionslist.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "net/net.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-DragDrop dragDrop(nullptr, DragDropSource::Empty);
-
-Item::Item(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped) :
- mId(0),
- mColor(ItemColor_zero),
- mQuantity(quantity),
- mTag(0),
- mImage(nullptr),
- mDescription(),
- mTags(),
- mCards(),
- mOptions(nullptr),
- mRefine(refine),
- mInvIndex(0),
- mType(type),
- mEquipment(equipment),
- mEquipped(equipped),
- mInEquipment(false),
- mIdentified(identified),
- mDamaged(damaged),
- mFavorite(favorite)
-{
- setId(id, color);
- for (int f = 0; f < maxCards; f ++)
- mCards[f] = 0;
-}
-
-Item::~Item()
-{
- if (mImage != nullptr)
- {
- mImage->decRef();
- mImage = nullptr;
- }
- delete2(mOptions);
- dragDrop.clearItem(this);
-}
-
-void Item::setId(const int id,
- const ItemColor color)
-{
- mId = id;
- mColor = color;
-
- // Types 0 and 1 are not equippable items.
- mEquipment = fromBool(id && CAST_S32(getInfo().getType())
- >= 2, Equipm);
-
- if (mImage != nullptr)
- mImage->decRef();
-
- const ItemInfo &info = getInfo();
- mTags = info.getTags();
-
- const std::string dye = combineDye2(pathJoin(
- paths.getStringValue("itemIcons"), info.getDisplay().image),
- info.getDyeIconColorsString(color));
- mImage = Loader::getImage(dye);
-
- if (mImage == nullptr)
- {
- mImage = Theme::getImageFromTheme(paths.getValue("unknownItemFile",
- "unknown-item.png"));
- }
-}
-
-bool Item::isHaveTag(const int tagId) const
-{
- const std::map <int, int>::const_iterator it = mTags.find(tagId);
- if (it == mTags.end())
- return false;
- return (*it).second > 0;
-}
-
-Image *Item::getImage(const int id,
- const ItemColor color)
-{
- const ItemInfo &info = ItemDB::get(id);
- Image *image = Loader::getImage(combineDye2(pathJoin(paths.getStringValue(
- "itemIcons"), info.getDisplay().image),
- info.getDyeIconColorsString(color)));
-
- if (image == nullptr)
- image = Theme::getImageFromTheme("unknown-item.png");
- return image;
-}
-
-std::string Item::getName() const
-{
- const ItemInfo &info = ItemDB::get(mId);
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- return info.getName();
- }
-#endif // TWMA_SUPPORT
- return info.getName(mColor);
-}
-
-void Item::setCard(const int index, const int id)
-{
- if (index < 0 || index >= maxCards)
- return;
- mCards[index] = id;
-}
-
-int Item::getCard(const int index) const
-{
- if (index < 0 || index >= maxCards)
- return 0;
- return mCards[index];
-}
-
-void Item::setCards(const int *const cards, const int size)
-{
- if (size < 0 || (cards == nullptr))
- return;
- int sz = size;
- if (sz > maxCards)
- sz = maxCards;
- for (int f = 0; f < sz; f ++)
- mCards[f] = cards[f];
-}
-
-void Item::addCard(const int card)
-{
- for (int f = 0; f < maxCards; f ++)
- {
- if (mCards[f] == 0)
- {
- mCards[f] = card;
- return;
- }
- }
-}
-
-void Item::setOptions(const ItemOptionsList *const options)
-{
- delete2(mOptions);
- mOptions = ItemOptionsList::copy(options);
-}
-
-void Item::updateColor()
-{
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- setId(mId, ItemColorManager::getColorFromCards(&mCards[0]));
-}
diff --git a/src/resources/item/item.h b/src/resources/item/item.h
deleted file mode 100644
index f1712d26a..000000000
--- a/src/resources/item/item.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_ITEM_H
-#define RESOURCES_ITEM_ITEM_H
-
-#include "const/resources/item/cards.h"
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/damaged.h"
-#include "enums/simpletypes/equipm.h"
-#include "enums/simpletypes/equipped.h"
-#include "enums/simpletypes/favorite.h"
-#include "enums/simpletypes/identified.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "resources/db/itemdb.h"
-
-#include "localconsts.h"
-
-class Image;
-
-struct ItemOptionsList;
-
-/**
- * Represents one or more instances of a certain item type.
- */
-class Item notfinal
-{
- public:
- /**
- * Constructor.
- */
- Item(const int id,
- const ItemTypeT type,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment,
- const Equipped equipped);
-
- A_DELETE_COPY(Item)
-
- /**
- * Destructor.
- */
- virtual ~Item();
-
- /**
- * Sets the item id, color the item type.
- */
- void setId(const int id, const ItemColor color);
-
- /**
- * Returns the item id.
- */
- int getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- /**
- * Returns the item image.
- */
- Image *getImage() const noexcept2 A_WARN_UNUSED
- { return mImage; }
-
- /**
- * Sets the number of items.
- */
- void setQuantity(const int quantity) noexcept2
- { mQuantity = quantity; }
-
- /**
- * Increases the number of items by the given amount.
- */
- void increaseQuantity(const int amount) noexcept2
- { mQuantity += amount; }
-
- /**
- * Returns the number of items.
- */
- int getQuantity() const noexcept2 A_WARN_UNUSED
- { return mQuantity; }
-
- /**
- * Sets whether this item is considered equipment.
- */
- void setEquipment(const Equipm equipment) noexcept2
- { mEquipment = equipment; }
-
- /**
- * Returns whether this item is considered equipment.
- */
- Equipm isEquipment() const noexcept2 A_WARN_UNUSED
- { return mEquipment; }
-
- /**
- * Sets whether this item is equipped.
- */
- void setEquipped(const Equipped equipped) noexcept2
- { mEquipped = equipped; }
-
- /**
- * Returns whether this item is equipped.
- */
- Equipped isEquipped() const noexcept2 A_WARN_UNUSED
- { return mEquipped; }
-
- /**
- * Sets this item refine level.
- */
- void setRefine(const uint8_t refine) noexcept2
- { mRefine = refine; }
-
- /**
- * Returns this item refine level.
- */
- uint8_t getRefine() const noexcept2 A_WARN_UNUSED
- { return mRefine; }
-
- /**
- * Sets whether this item is in equipment.
- */
- void setInEquipment(const bool inEquipment) noexcept2
- { mInEquipment = inEquipment; }
-
- /**
- * Returns whether this item is in equipment.
- */
- bool isInEquipment() const noexcept2 A_WARN_UNUSED
- { return mInEquipment; }
-
- /**
- * Sets the inventory index of this item.
- */
- void setInvIndex(const int index) noexcept2
- { mInvIndex = index; }
-
- /**
- * Returns the inventory index of this item.
- */
- int getInvIndex() const noexcept2 A_WARN_UNUSED
- { return mInvIndex; }
-
- /**
- * Returns information about this item type.
- */
- const ItemInfo &getInfo() const A_WARN_UNUSED
- { return ItemDB::get(mId); }
-
- std::string getName() const A_WARN_UNUSED;
-
- static Image *getImage(const int id,
- const ItemColor color) A_WARN_UNUSED;
-
- bool isHaveTag(const int tagId) const A_WARN_UNUSED;
-
- ItemColor getColor() const noexcept2 A_WARN_UNUSED
- { return mColor; }
-
- void setColor(const ItemColor color) noexcept2
- { mColor = color; }
-
- const std::string &getDescription() const noexcept2 A_WARN_UNUSED
- { return mDescription; }
-
- void setIdentified(const Identified b) noexcept2
- { mIdentified = b; }
-
- Identified getIdentified() const noexcept2 A_WARN_UNUSED
- { return mIdentified; }
-
- void setDamaged(const Damaged b) noexcept2
- { mDamaged = b; }
-
- Damaged getDamaged() const noexcept2 A_WARN_UNUSED
- { return mDamaged; }
-
- void setFavorite(const Favorite b) noexcept2
- { mFavorite = b; }
-
- Favorite getFavorite() const noexcept2 A_WARN_UNUSED
- { return mFavorite; }
-
- void setCard(const int index, const int id);
-
- int getCard(const int index) const;
-
- void setCards(const int *const cards, const int size);
-
- const int *getCards() const noexcept2 A_WARN_UNUSED
- { return mCards; }
-
- void setOptions(const ItemOptionsList *const options);
-
- const ItemOptionsList *getOptions() const noexcept2 A_WARN_UNUSED
- { return mOptions; }
-
- void setType(const ItemTypeT type) noexcept2
- { mType = type; }
-
- ItemTypeT getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- void setTag(const int tag) noexcept2
- { mTag = tag; }
-
- int getTag() const noexcept2 A_WARN_UNUSED
- { return mTag; }
-
- void addCard(const int card);
-
- void updateColor();
-
- static constexpr bool isItem(const int id) noexcept2 A_WARN_UNUSED
- {
- return id != 0 &&
- id != CARD0_FORGE &&
- id != CARD0_CREATE &&
- id != CARD0_PET;
- }
-
- int mId; /**< Item id. */
- ItemColor mColor;
- int mQuantity; /**< Number of items. */
- int mTag;
-
- protected:
- Image *mImage; /**< Item image. */
- std::string mDescription;
- std::map <int, int> mTags;
- int mCards[maxCards];
- const ItemOptionsList *mOptions;
- uint8_t mRefine; /**< Item refine level. */
- int mInvIndex; /**< Inventory index. */
- ItemTypeT mType; /**< Item type. */
- Equipm mEquipment; /**< Item is equipment. */
- Equipped mEquipped; /**< Item is equipped. */
- bool mInEquipment; /**< Item is in equipment */
- Identified mIdentified;
- Damaged mDamaged;
- Favorite mFavorite;
-};
-
-#endif // RESOURCES_ITEM_ITEM_H
diff --git a/src/resources/item/itemfieldtype.h b/src/resources/item/itemfieldtype.h
deleted file mode 100644
index e7a6424b9..000000000
--- a/src/resources/item/itemfieldtype.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_ITEMFIELDTYPE_H
-#define RESOURCES_ITEM_ITEMFIELDTYPE_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct ItemFieldType final
-{
- ItemFieldType(const std::string &name0,
- const std::string &description0,
- const bool sign0) :
- name(name0),
- description(description0),
- sign(sign0)
- { }
-
- A_DELETE_COPY(ItemFieldType)
-
- const std::string name;
- const std::string description;
- const bool sign;
-};
-
-#endif // RESOURCES_ITEM_ITEMFIELDTYPE_H
diff --git a/src/resources/item/itemoption.h b/src/resources/item/itemoption.h
deleted file mode 100644
index c4327622a..000000000
--- a/src/resources/item/itemoption.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_ITEMOPTION_H
-#define RESOURCES_ITEM_ITEMOPTION_H
-
-#include "localconsts.h"
-
-struct ItemOption final
-{
- ItemOption() :
- index(0U),
- value(0)
- { }
-
- A_DELETE_COPY(ItemOption)
-
- uint16_t index;
- int16_t value;
-};
-
-#endif // RESOURCES_ITEM_ITEMOPTION_H
diff --git a/src/resources/item/itemoptionslist.h b/src/resources/item/itemoptionslist.h
deleted file mode 100644
index f5b3365f5..000000000
--- a/src/resources/item/itemoptionslist.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_ITEMOPTIONSLIST_H
-#define RESOURCES_ITEM_ITEMOPTIONSLIST_H
-
-#include "const/resources/item/itemoptions.h"
-
-#include "resources/item/itemoption.h"
-
-#include "localconsts.h"
-
-struct ItemOptionsList final
-{
- explicit ItemOptionsList(const size_t amount0) :
- options(nullptr),
- amount(amount0),
- pointer(0U)
- {
- options = new ItemOption[amount];
- }
-
- ItemOptionsList() :
- options(nullptr),
- amount(maxItemOptions),
- pointer(0U)
- {
- options = new ItemOption[amount];
- }
-
- A_DELETE_COPY(ItemOptionsList)
-
- ~ItemOptionsList()
- {
- delete [] options;
- options = nullptr;
- }
-
- void add(const uint16_t index,
- const uint16_t value)
- {
- if (pointer >= amount)
- return;
- options[pointer].index = index;
- options[pointer].value = value;
- pointer ++;
- }
-
- static ItemOptionsList *copy(const ItemOptionsList *const options0)
- {
- if (options0 == nullptr)
- return nullptr;
-
- const size_t amount0 = options0->amount;
- ItemOptionsList *const obj = new ItemOptionsList(amount0);
- for (size_t f = 0; f < amount0; f ++)
- {
- obj->options[f].index = options0->options[f].index;
- obj->options[f].value = options0->options[f].value;
- }
- obj->amount = options0->amount;
- obj->pointer = options0->pointer;
- return obj;
- }
-
- size_t size() const
- {
- if (pointer < amount)
- return pointer;
- return amount;
- }
-
- const ItemOption &get(const size_t index) const
- {
- return options[index];
- }
-
- ItemOption *options;
- size_t amount;
- size_t pointer;
-};
-
-#endif // RESOURCES_ITEM_ITEMOPTIONSLIST_H
diff --git a/src/resources/item/shopitem.cpp b/src/resources/item/shopitem.cpp
deleted file mode 100644
index 76b269cca..000000000
--- a/src/resources/item/shopitem.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/item/shopitem.h"
-
-#include "resources/iteminfo.h"
-
-#include "utils/stringutils.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-#endif // TMWA_SUPPORT
-
-#include "resources/db/unitsdb.h"
-
-#include "debug.h"
-
-ShopItem::ShopItem(const int inventoryIndex,
- const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int quantity,
- const int price,
- const std::string &currency) :
- Item(id, type, 0, 0, color,
- Identified_true,
- Damaged_false,
- Favorite_false,
- Equipm_false,
- Equipped_false),
- mDisplayName(),
- mCurrency(currency),
- mDuplicates(),
- mPrice(price),
- mUsedQuantity(0),
- mShowQuantity(true),
- mVisible(true),
- mDisabled(false)
-{
- updateDisplayName(quantity);
- setInvIndex(inventoryIndex);
- addDuplicate(inventoryIndex, quantity);
-}
-
-ShopItem::ShopItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int price,
- const std::string &currency) :
- Item(id, type, 0, 0, color,
- Identified_true,
- Damaged_false,
- Favorite_false,
- Equipm_false,
- Equipped_false),
- mDisplayName(),
- mCurrency(currency),
- mDuplicates(),
- mPrice(price),
- mUsedQuantity(0),
- mShowQuantity(false),
- mVisible(true),
- mDisabled(false)
-{
- updateDisplayName(0);
- setInvIndex(-1);
- addDuplicate(-1, 0);
-}
-
-ShopItem::~ShopItem()
-{
- /** Clear all remaining duplicates on Object destruction. */
- while (!mDuplicates.empty())
- {
- delete mDuplicates.top();
- mDuplicates.pop();
- }
-}
-
-void ShopItem::updateDisplayName(const int quantity)
-{
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- mDisplayName = std::string(getInfo().getName());
- else
-#endif // TMWA_SUPPORT
- mDisplayName = std::string(getInfo().getName(mColor));
- if (mPrice != 0)
- {
- mDisplayName.append(" (").append(
- UnitsDb::formatCurrency(mCurrency, mPrice)).append(") ");
- }
- if (mShowQuantity && quantity > 1)
- mDisplayName.append("[").append(toString(quantity)).append("]");
- if (mUsedQuantity > 0)
- mDisplayName.append(" +").append(toString(mUsedQuantity));
-}
-
-void ShopItem::update()
-{
- updateDisplayName(mQuantity);
-}
-
-void ShopItem::addDuplicate(const int inventoryIndex, const int quantity)
-{
- DuplicateItem *const di = new DuplicateItem;
- di->inventoryIndex = inventoryIndex;
- di->quantity = quantity;
- mDuplicates.push(di);
- mQuantity += quantity;
-}
-
-void ShopItem::addDuplicate()
-{
- DuplicateItem *const di = new DuplicateItem;
- di->inventoryIndex = -1;
- di->quantity = 0;
- mDuplicates.push(di);
-}
-
-int ShopItem::sellCurrentDuplicate(const int quantity)
-{
- DuplicateItem* dupl = mDuplicates.top();
- if (dupl == nullptr)
- return 0;
-
- const int sellCount = quantity <= dupl->quantity
- ? quantity : dupl->quantity;
- dupl->quantity -= sellCount;
- mQuantity -= sellCount;
- if (dupl->quantity == 0)
- {
- delete dupl;
- mDuplicates.pop();
- }
- return sellCount;
-}
-
-void ShopItem::increaseUsedQuantity(const int amount)
-{
- if (mShowQuantity && (mQuantity != 0))
- {
- if (mQuantity < mUsedQuantity + amount ||
- mUsedQuantity + amount < 0)
- {
- return;
- }
- }
- else if (mUsedQuantity + amount < 0)
- {
- return;
- }
-
- mUsedQuantity += amount;
-}
diff --git a/src/resources/item/shopitem.h b/src/resources/item/shopitem.h
deleted file mode 100644
index 7596d0269..000000000
--- a/src/resources/item/shopitem.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEM_SHOPITEM_H
-#define RESOURCES_ITEM_SHOPITEM_H
-
-#include "resources/item/item.h"
-
-#include <stack>
-
-#include "localconsts.h"
-
-/**
- * Represents an item in a shop inventory. It can store quantity and inventory
- * indices of duplicate entries in the shop as well.
- */
-class ShopItem final : public Item
-{
- public:
- /**
- * Constructor. Creates a new ShopItem.
- *
- * @param inventoryIndex the inventory index of the item
- * @param id the id of the item
- * @param quantity number of available copies of the item
- * @param price price of the item
- */
- ShopItem(const int inventoryIndex,
- const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int quantity,
- const int price,
- const std::string &currency);
-
- /**
- * Constructor. Creates a new ShopItem. Inventory index will be set to
- * -1 and quantity to 0.
- *
- * @param id the id of the item
- * @param price price of the item
- */
- ShopItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int price,
- const std::string &currency);
-
- A_DELETE_COPY(ShopItem)
-
- /**
- * Destructor.
- */
- ~ShopItem();
-
- /**
- * Add a duplicate. Id and price will be taken from this item.
- *
- * @param inventoryIndex the inventory index of the item
- * @param quantity number of available copies of the item
- */
- void addDuplicate(const int inventoryIndex, const int quantity);
-
- /**
- * Add a duplicate. Id and price will be taken from this item.
- * Needed for compatibility with ShopDuplicateItems (see) class
- * documentation).
- */
- void addDuplicate();
-
- void update();
-
- /**
- * Gets the quantity of the currently topmost duplicate.
- *
- * @return the quantity of the currently topmost duplicate
- */
- int getCurrentQuantity() const A_WARN_UNUSED
- {
- return mDuplicates.empty() ? 0 : mDuplicates.top()->quantity;
- }
-
- /**
- * Gets the inventory index of the currently topmost duplicate.
- *
- * @return the inventory index of the currently topmost duplicate
- */
- int getCurrentInvIndex() const A_WARN_UNUSED
- {
- return mDuplicates.empty() ? mInvIndex :
- mDuplicates.top()->inventoryIndex;
- }
-
- /**
- * Reduces the quantity of the topmost duplicate by the specified
- * amount. Also reduces the total quantity of this DuplicateItem.
- * Empty duplicates are automatically removed.
- *
- * If the amount is bigger than the quantity of the current topmost,
- * only sell as much as possible. Returns the amount actually sold (do
- * not ignore the return value!)
- *
- * @return the amount, that actually was sold.
- */
- int sellCurrentDuplicate(const int quantity);
-
- /**
- * Gets the price of the item.
- *
- * @return the price of the item
- */
- int getPrice() const noexcept2 A_WARN_UNUSED
- { return mPrice; }
-
- /**
- * Gets the display name for the item in the shop list.
- *
- * @return the display name for the item in the shop list
- */
- const std::string &getDisplayName() const noexcept2 A_WARN_UNUSED
- { return mDisplayName; }
-
- void setVisible(const bool b) noexcept2
- { mVisible = b; }
-
- bool isVisible() const noexcept2 A_WARN_UNUSED
- { return mVisible; }
-
- void increaseUsedQuantity(const int amount);
-
- int getUsedQuantity() const noexcept2 A_WARN_UNUSED
- { return mUsedQuantity; }
-
- void setDisabled(const bool b) noexcept2
- { mDisabled = b; }
-
- bool getDisabled() const noexcept2 A_WARN_UNUSED
- { return mDisabled; }
-
- protected:
- void updateDisplayName(const int quantity);
-
- std::string mDisplayName;
- std::string mCurrency;
-
- /**
- * Struct to keep track of duplicates.
- */
- typedef struct
- {
- int inventoryIndex;
- int quantity;
- } DuplicateItem;
- std::stack<DuplicateItem*> mDuplicates; /** <-- Stores duplicates */
- int mPrice;
- int mUsedQuantity;
- bool mShowQuantity;
- bool mVisible;
- bool mDisabled;
-};
-
-#endif // RESOURCES_ITEM_SHOPITEM_H
diff --git a/src/resources/itemcolordata.h b/src/resources/itemcolordata.h
deleted file mode 100644
index 60eb247ff..000000000
--- a/src/resources/itemcolordata.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEMCOLORDATA_H
-#define RESOURCES_ITEMCOLORDATA_H
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class ItemColorData final
-{
- public:
- ItemColorData() :
- id(ItemColor_zero),
- name(),
- color()
- { }
-
- ItemColorData(const ItemColor id0,
- const std::string &name0,
- const std::string &color0) :
- id(id0),
- name(name0),
- color(color0)
- {
- }
-
- A_DEFAULT_COPY(ItemColorData)
-
- ItemColor id;
- std::string name;
- std::string color;
-};
-
-#endif // RESOURCES_ITEMCOLORDATA_H
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
deleted file mode 100644
index 60810e000..000000000
--- a/src/resources/iteminfo.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/iteminfo.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "const/resources/map/map.h"
-
-#include "enums/resources/spritedirection.h"
-
-#include "resources/itemmenuitem.h"
-
-#include "resources/db/colordb.h"
-#include "resources/db/itemdb.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-ItemInfo::ItemInfo() :
- mDisplay(),
- mMissile(),
- mName(),
- mNameEn(),
- mDescription(),
- mEffect(),
- mUseButton(),
- mUseButton2(),
- mType(ItemDbType::UNUSABLE),
- mWeight(0),
- mView(0),
- mId(0),
- mIsRemoveSprites(false),
- mSpriteToItemReplaceList(),
- mAttackAction(SpriteAction::INVALID),
- mSkyAttackAction(SpriteAction::INVALID),
- mWaterAttackAction(SpriteAction::INVALID),
- mRideAttackAction(SpriteAction::INVALID),
- mAttackRange(0),
- mMissileParticle(),
- mAnimationFiles(),
- mSounds(),
- mTags(),
- mColorsList(nullptr),
- mIconColorsList(nullptr),
- mInventoryMenu(),
- mStorageMenu(),
- mCartMenu(),
- mColorsListName(),
- mIconColorsListName(),
- mCardColor(ItemColor_zero),
- mHitEffectId(-1),
- mCriticalHitEffectId(-1),
- mMissEffectId(-1),
- maxFloorOffsetX(mapTileSize),
- maxFloorOffsetY(mapTileSize),
- mPickupCursor(Cursor::CURSOR_POINTER),
- mProtected(false)
-{
- for (int f = 0; f < 10; f ++)
- {
- mSpriteToItemReplaceMap[f] = nullptr;
- mDrawBefore[f] = -1;
- mDrawAfter[f] = -1;
- mDrawPriority[f] = 0;
- }
-}
-
-ItemInfo::~ItemInfo()
-{
- delete_all(mSpriteToItemReplaceList);
- mSpriteToItemReplaceList.clear();
- for (int f = 0; f < 10; f ++)
- mSpriteToItemReplaceMap[f] = nullptr;
-}
-
-const std::string &ItemInfo::getSprite(const GenderT gender,
- const BeingTypeId race) const
-{
- if (mView != 0)
- {
- // Forward the request to the item defining how to view this item
- return ItemDB::get(mView).getSprite(gender, race);
- }
- static const std::string empty;
- std::map<int, std::string>::const_iterator i =
- mAnimationFiles.find(CAST_S32(gender) +
- toInt(race, int) * 4);
-
- if (i != mAnimationFiles.end())
- return i->second;
- i = mAnimationFiles.find(CAST_S32(gender));
- if (i != mAnimationFiles.end())
- return i->second;
- return empty;
-}
-
-void ItemInfo::setAttackAction(const std::string &attackAction)
-{
- if (attackAction.empty())
- mAttackAction = SpriteAction::ATTACK; // (Equal to unarmed animation)
- else
- mAttackAction = attackAction;
-}
-
-void ItemInfo::setSkyAttackAction(const std::string &attackAction)
-{
- if (attackAction.empty())
- mSkyAttackAction = SpriteAction::ATTACKSKY;
- else
- mSkyAttackAction = attackAction;
-}
-
-void ItemInfo::setWaterAttackAction(const std::string &attackAction)
-{
- if (attackAction.empty())
- mWaterAttackAction = SpriteAction::ATTACKWATER;
- else
- mWaterAttackAction = attackAction;
-}
-
-void ItemInfo::setRideAttackAction(const std::string &attackAction)
-{
- if (attackAction.empty())
- mRideAttackAction = SpriteAction::ATTACKRIDE;
- else
- mRideAttackAction = attackAction;
-}
-
-void ItemInfo::addSound(const ItemSoundEvent::Type event,
- const std::string &filename, const int delay)
-{
- mSounds[event].push_back(SoundInfo(
- filename,
- delay));
-}
-
-const SoundInfo &ItemInfo::getSound(const ItemSoundEvent::Type event) const
-{
- static const SoundInfo empty("", 0);
- std::map<ItemSoundEvent::Type, SoundInfoVect>::const_iterator i;
-
- i = mSounds.find(event);
-
- if (i == mSounds.end())
- return empty;
- return (!i->second.empty()) ? i->second[CAST_U32(rand())
- % i->second.size()] : empty;
-}
-
-IntMap *ItemInfo::addReplaceSprite(const int sprite,
- const int direction)
-{
- if (direction < 0 || direction >= 10)
- return nullptr;
-
- SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction];
-
- if (spMap == nullptr)
- {
- spMap = new SpriteToItemMap;
- mSpriteToItemReplaceMap[direction] = spMap;
- mSpriteToItemReplaceList.push_back(spMap);
- }
-
- SpriteToItemMap::iterator it = spMap->find(sprite);
- if (it == spMap->end())
- {
- IntMap tmp;
- (*mSpriteToItemReplaceMap[direction])[sprite] = tmp;
- it = mSpriteToItemReplaceMap[direction]->find(sprite);
- }
- return &it->second;
-}
-
-void ItemInfo::setColorsList(const std::string &name)
-{
- if (name.empty())
- {
- mColorsList = nullptr;
- mColorsListName.clear();
- }
- else
- {
- mColorsList = ColorDB::getColorsList(name);
- mColorsListName = name;
- }
-}
-
-void ItemInfo::setIconColorsList(const std::string &name)
-{
- if (name.empty())
- {
- mIconColorsList = nullptr;
- mIconColorsListName.clear();
- }
- else
- {
- mIconColorsList = ColorDB::getColorsList(name);
- mIconColorsListName = name;
- }
-}
-
-std::string ItemInfo::getDyeColorsString(const ItemColor color) const
-{
- if ((mColorsList == nullptr) || mColorsListName.empty())
- return "";
-
- const std::map <ItemColor, ItemColorData>::const_iterator
- it = mColorsList->find(color);
- if (it == mColorsList->end())
- return "";
-
- return it->second.color;
-}
-
-std::string ItemInfo::getDyeIconColorsString(const ItemColor color) const
-{
- if ((mIconColorsList == nullptr) || mIconColorsListName.empty())
- return "";
-
- const std::map <ItemColor, ItemColorData>::const_iterator
- it = mIconColorsList->find(color);
- if (it == mIconColorsList->end())
- return "";
-
- return it->second.color;
-}
-
-const std::string ItemInfo::getDescription(const ItemColor color) const
-{
- return replaceColors(mDescription, color);
-}
-
-const std::string ItemInfo::getName(const ItemColor color) const
-{
- return replaceColors(mName, color);
-}
-
-const std::string ItemInfo::getNameEn(const ItemColor color) const
-{
- return replaceColors(mNameEn, color);
-}
-
-const std::string ItemInfo::replaceColors(std::string str,
- const ItemColor color) const
-{
- std::string name;
- if ((mColorsList != nullptr) && !mColorsListName.empty())
- {
- const std::map <ItemColor, ItemColorData>::const_iterator
- it = mColorsList->find(color);
- if (it == mColorsList->end())
- name = "unknown";
- else
- name = it->second.name;
- }
- else
- {
- name = "unknown";
- }
-
- str = replaceAll(str, "%color%", name);
- if (!name.empty())
- name[0] = CAST_S8(toupper(name[0]));
-
- return replaceAll(str, "%Color%", name);
-}
-
-const SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(const int direction)
- const
-{
- if (direction < 0 || direction >= 10)
- return nullptr;
-
- const SpriteToItemMap *const spMap = mSpriteToItemReplaceMap[direction];
- if (spMap != nullptr)
- return spMap;
- if (direction == SpriteDirection::UPLEFT
- || direction == SpriteDirection::UPRIGHT)
- {
- return mSpriteToItemReplaceMap[SpriteDirection::UP];
- }
-
- if (direction == SpriteDirection::DOWNLEFT
- || direction == SpriteDirection::DOWNRIGHT)
- {
- return mSpriteToItemReplaceMap[SpriteDirection::DOWN];
- }
-
- return nullptr;
-}
-
-void ItemInfo::setSpriteOrder(int *const ptr,
- const int direction,
- const int n,
- const int def)
-{
- switch (direction)
- {
- case -1:
- {
- for (int f = 0; f < 10; f ++)
- {
- if (ptr[f] == def)
- ptr[f] = n;
- }
- return;
- }
- case -2:
- {
- ptr[SpriteDirection::DOWN] = n;
- ptr[SpriteDirection::DOWNLEFT] = n;
- ptr[SpriteDirection::DOWNRIGHT] = n;
- return;
- }
- case -3:
- {
- ptr[SpriteDirection::UP] = n;
- ptr[SpriteDirection::UPLEFT] = n;
- ptr[SpriteDirection::UPRIGHT] = n;
- return;
- }
- default:
- break;
- }
- if (direction < 0 || direction >= 9)
- return;
-
- if (direction == SpriteDirection::UP)
- {
- if (ptr[SpriteDirection::UPLEFT] == def)
- ptr[SpriteDirection::UPLEFT] = n;
- if (ptr[SpriteDirection::UPRIGHT] == def)
- ptr[SpriteDirection::UPRIGHT] = n;
- }
- else if (direction == SpriteDirection::DOWN)
- {
- if (ptr[SpriteDirection::DOWNLEFT] == def)
- ptr[SpriteDirection::DOWNLEFT] = n;
- if (ptr[SpriteDirection::DOWNRIGHT] == def)
- ptr[SpriteDirection::DOWNRIGHT] = n;
- }
- ptr[direction] = n;
-}
-
-void ItemInfo::setDrawBefore(const int direction, const int n)
-{
- setSpriteOrder(&mDrawBefore[0], direction, n);
-}
-
-void ItemInfo::setDrawAfter(const int direction, const int n)
-{
- setSpriteOrder(&mDrawAfter[0], direction, n);
-}
-
-void ItemInfo::setDrawPriority(const int direction, const int n)
-{
- setSpriteOrder(&mDrawPriority[0], direction, n, 0);
-}
-
-int ItemInfo::getDrawBefore(const int direction) const
-{
- if (direction < 0 || direction >= 10)
- return -1;
- return mDrawBefore[direction];
-}
-
-int ItemInfo::getDrawAfter(const int direction) const
-{
- if (direction < 0 || direction >= 10)
- return -1;
- return mDrawAfter[direction];
-}
-
-int ItemInfo::getDrawPriority(const int direction) const
-{
- if (direction < 0 || direction >= 10)
- return 0;
- return mDrawPriority[direction];
-}
-
-void ItemInfo::setSprite(const std::string &animationFile,
- const GenderT gender,
- const int race)
-{
- mAnimationFiles[CAST_S32(gender) + race * 4] = animationFile;
-}
-
-std::string ItemInfo::getColorName(const ItemColor idx) const
-{
- if (mColorsList == nullptr)
- return std::string();
-
- const std::map <ItemColor, ItemColorData>::const_iterator
- it = mColorsList->find(idx);
- if (it == mColorsList->end())
- {
- reportAlways("Color %d for palette %s not found",
- CAST_S32(idx),
- mColorsListName.c_str());
- return std::string();
- }
- return it->second.name;
-}
-
-std::string ItemInfo::getColor(const ItemColor idx) const
-{
- if (mColorsList == nullptr)
- return std::string();
-
- const std::map <ItemColor, ItemColorData>::const_iterator
- it = mColorsList->find(idx);
- if (it == mColorsList->end())
- {
- reportAlways("Color %d for palette %s not found",
- CAST_S32(idx),
- mColorsListName.c_str());
- return std::string();
- }
- return it->second.color;
-}
-
-std::string ItemInfo::getIconColorName(const ItemColor idx) const
-{
- if (mIconColorsList == nullptr)
- return std::string();
-
- const std::map <ItemColor, ItemColorData>::const_iterator
- it = mIconColorsList->find(idx);
- if (it == mIconColorsList->end())
- {
- reportAlways("Color %d for palette %s not found",
- CAST_S32(idx),
- mColorsListName.c_str());
- return std::string();
- }
- return it->second.name;
-}
-
-std::string ItemInfo::getIconColor(const ItemColor idx) const
-{
- if (mIconColorsList == nullptr)
- return std::string();
-
- const std::map <ItemColor, ItemColorData>::const_iterator
- it = mIconColorsList->find(idx);
- if (it == mIconColorsList->end())
- {
- reportAlways("Color %d for palette %s not found",
- CAST_S32(idx),
- mColorsListName.c_str());
- return std::string();
- }
- return it->second.color;
-}
-
-const std::string ItemInfo::getLink() const
-{
- return strprintf("[@@%d|%s@@]", mId, mName.c_str());
-}
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
deleted file mode 100644
index e1fe30b33..000000000
--- a/src/resources/iteminfo.h
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEMINFO_H
-#define RESOURCES_ITEMINFO_H
-
-#include "enums/being/gender.h"
-
-#include "enums/resources/item/itemdbtype.h"
-
-#include "enums/simpletypes/beingtypeid.h"
-
-#include "resources/cursors.h"
-#include "resources/itemcolordata.h"
-#include "resources/missileinfo.h"
-#include "resources/soundinfo.h"
-
-#include "resources/sprite/spritedisplay.h"
-
-#include "utils/cast.h"
-#include "utils/intmap.h"
-
-struct ItemMenuItem;
-
-// sprite, <itemfrom, itemto>
-typedef std::map<int, IntMap> SpriteToItemMap;
-typedef SpriteToItemMap::const_iterator SpriteToItemMapCIter;
-
-/**
- * Defines a class for storing item infos. This includes information used when
- * the item is equipped.
- */
-class ItemInfo final
-{
- public:
- /**
- * Constructor.
- */
- ItemInfo();
-
- A_DELETE_COPY(ItemInfo)
-
- ~ItemInfo();
-
- void setId(const int id) noexcept2
- { mId = id; }
-
- int getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- void setName(const std::string &name) noexcept2
- { mName = name; }
-
- const std::string &getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- const std::string getName(const ItemColor color)
- const A_WARN_UNUSED;
-
- void setNameEn(const std::string &name) noexcept2
- { mNameEn = name; }
-
- const std::string &getNameEn() const noexcept2 A_WARN_UNUSED
- { return mNameEn; }
-
- const std::string getNameEn(const ItemColor color)
- const A_WARN_UNUSED;
-
- const std::string getLink() const A_WARN_UNUSED;
-
- void setDisplay(const SpriteDisplay &display) noexcept2
- { mDisplay = display; }
-
- const SpriteDisplay &getDisplay() const noexcept2 A_WARN_UNUSED
- { return mDisplay; }
-
- void setDescription(const std::string &description) noexcept2
- { mDescription = description; }
-
- const std::string &getDescription() const noexcept2 A_WARN_UNUSED
- { return mDescription; }
-
- const std::string getDescription(const ItemColor color)
- const A_WARN_UNUSED;
-
- void setEffect(const std::string &effect) noexcept2
- { mEffect = effect; }
-
- const std::string &getEffect() const noexcept2 A_WARN_UNUSED
- { return mEffect; }
-
- void setType(const ItemDbTypeT type) noexcept2
- { mType = type; }
-
- void setUseButton(const std::string &str) noexcept2
- { mUseButton = str; }
-
- const std::string &getUseButton() const noexcept2 A_WARN_UNUSED
- { return mUseButton; }
-
- void setUseButton2(const std::string &str) noexcept2
- { mUseButton2 = str; }
-
- const std::string &getUseButton2() const noexcept2 A_WARN_UNUSED
- { return mUseButton2; }
-
- ItemDbTypeT getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- void setWeight(const int weight) noexcept2
- { mWeight = weight; }
-
- int getWeight() const noexcept2 A_WARN_UNUSED
- { return mWeight; }
-
- int getView() const noexcept2 A_WARN_UNUSED
- { return mView; }
-
- void setView(const int view) noexcept2
- { mView = view; }
-
- void setSprite(const std::string &animationFile,
- const GenderT gender, const int race);
-
- const std::string &getSprite(const GenderT gender,
- const BeingTypeId race)
- const A_WARN_UNUSED;
-
- void setAttackAction(const std::string &attackAction);
-
- void setSkyAttackAction(const std::string &attackAction);
-
- void setWaterAttackAction(const std::string &attackAction);
-
- void setRideAttackAction(const std::string &attackAction);
-
- // Handlers for seting and getting the string
- // used for particles when attacking
- void setMissileParticleFile(const std::string &s) noexcept2
- { mMissile.particle = s; }
-
- MissileInfo &getMissile() noexcept2 A_WARN_UNUSED
- { return mMissile; }
-
- const MissileInfo &getMissileConst() const noexcept2 A_WARN_UNUSED
- { return mMissile; }
-
- void setHitEffectId(const int s) noexcept2
- { mHitEffectId = s; }
-
- int getHitEffectId() const noexcept2 A_WARN_UNUSED
- { return mHitEffectId; }
-
- void setCriticalHitEffectId(const int s) noexcept2
- { mCriticalHitEffectId = s; }
-
- int getCriticalHitEffectId() const noexcept2 A_WARN_UNUSED
- { return mCriticalHitEffectId; }
-
- void setMissEffectId(const int s) noexcept2
- { mMissEffectId = s; }
-
- int getMissEffectId() const noexcept2 A_WARN_UNUSED
- { return mMissEffectId; }
-
- const std::string &getAttackAction() const noexcept2 A_WARN_UNUSED
- { return mAttackAction; }
-
- const std::string &getSkyAttackAction() const noexcept2 A_WARN_UNUSED
- { return mSkyAttackAction; }
-
- const std::string &getWaterAttackAction() const noexcept2 A_WARN_UNUSED
- { return mWaterAttackAction; }
-
- const std::string &getRideAttackAction() const noexcept2 A_WARN_UNUSED
- { return mRideAttackAction; }
-
- int getAttackRange() const noexcept2 A_WARN_UNUSED
- { return mAttackRange; }
-
- void setAttackRange(const int r) noexcept2
- { mAttackRange = r; }
-
- void addSound(const ItemSoundEvent::Type event,
- const std::string &filename,
- const int delay);
-
- const SoundInfo &getSound(const ItemSoundEvent::Type event)
- const A_WARN_UNUSED;
-
- int getDrawBefore(const int direction) const A_WARN_UNUSED;
-
- void setDrawBefore(const int direction, const int n);
-
- int getDrawAfter(const int direction) const A_WARN_UNUSED;
-
- void setDrawAfter(const int direction, const int n);
-
- int getDrawPriority(const int direction) const A_WARN_UNUSED;
-
- void setDrawPriority(const int direction, const int n);
-
- const IntMap &getTags() const noexcept2 A_WARN_UNUSED
- { return mTags; }
-
- void addTag(const int tag)
- { mTags[tag] = 1; }
-
- void setRemoveSprites() noexcept2
- { mIsRemoveSprites = true; }
-
- bool isRemoveSprites() const noexcept2 A_WARN_UNUSED
- { return mIsRemoveSprites; }
-
- void setMaxFloorOffsetX(const int i) noexcept2
- { maxFloorOffsetX = i; }
-
- void setMaxFloorOffsetY(const int i) noexcept2
- { maxFloorOffsetY = i; }
-
- int getMaxFloorOffsetX() const noexcept2 A_WARN_UNUSED
- { return maxFloorOffsetX; }
-
- int getMaxFloorOffsetY() const noexcept2 A_WARN_UNUSED
- { return maxFloorOffsetY; }
-
- bool isRemoveItemId(int id) const A_WARN_UNUSED;
-
- void setCardColor(const ItemColor color) noexcept2
- { mCardColor = color; }
-
- ItemColor getCardColor() const noexcept2
- { return mCardColor; }
-
- int getReplaceToSpriteId(int id) const A_WARN_UNUSED;
-
- IntMap *addReplaceSprite(const int sprite,
- const int direction);
-
- const SpriteToItemMap *getSpriteToItemReplaceMap(const int directions)
- const A_WARN_UNUSED;
-
- std::string getDyeColorsString(const ItemColor color)
- const A_WARN_UNUSED;
-
- std::string getDyeIconColorsString(const ItemColor color)
- const A_WARN_UNUSED;
-
- void setColorsList(const std::string &name);
-
- void setIconColorsList(const std::string &name);
-
- bool isHaveColors() const noexcept2 A_WARN_UNUSED
- { return !mColorsListName.empty(); }
-
- bool isHaveIconColors() const noexcept2 A_WARN_UNUSED
- { return !mIconColorsListName.empty(); }
-
- std::string getColorsListName() const noexcept2 A_WARN_UNUSED
- { return mColorsListName; }
-
- std::string getIconColorsListName() const noexcept2 A_WARN_UNUSED
- { return mIconColorsListName; }
-
- const std::string replaceColors(std::string str,
- const ItemColor color)
- const A_WARN_UNUSED;
-
- void setPickupCursor(const std::string &cursor)
- { return setPickupCursor(Cursors::stringToCursor(cursor)); }
-
- void setPickupCursor(const CursorT &cursor) noexcept2
- { mPickupCursor = cursor; }
-
- CursorT getPickupCursor() const noexcept2 A_WARN_UNUSED
- { return mPickupCursor; }
-
- void setProtected(const bool b) noexcept2
- { mProtected = b; }
-
- bool isProtected() const noexcept2 A_WARN_UNUSED
- { return mProtected; }
-
- int getColorsSize() const noexcept2 A_WARN_UNUSED
- { return mColorsList != nullptr ? CAST_S32(mColorsList->size()) : 0; }
-
- int getIconColorsSize() const noexcept2 A_WARN_UNUSED
- {
- return mIconColorsList != nullptr ?
- CAST_S32(mIconColorsList->size()) : 0;
- }
-
- std::string getColorName(const ItemColor idx) const;
- std::string getColor(const ItemColor idx) const;
-
- std::string getIconColorName(const ItemColor idx) const;
- std::string getIconColor(const ItemColor idx) const;
-
- STD_VECTOR<ItemMenuItem> &getInventoryMenu()
- { return mInventoryMenu; }
- STD_VECTOR<ItemMenuItem> &getStorageMenu()
- { return mStorageMenu; }
- STD_VECTOR<ItemMenuItem> &getCartMenu()
- { return mCartMenu; }
-
- const STD_VECTOR<ItemMenuItem> &getInventoryMenuConst() const A_CONST
- { return mInventoryMenu; }
- const STD_VECTOR<ItemMenuItem> &getStorageMenuConst() const A_CONST
- { return mStorageMenu; }
- const STD_VECTOR<ItemMenuItem> &getCartMenuConst() const A_CONST
- { return mCartMenu; }
-
- int mDrawBefore[10];
- int mDrawAfter[10];
- int mDrawPriority[10];
-
- private:
- static void setSpriteOrder(int *const ptr,
- const int direction,
- const int n,
- const int def = -1) A_NONNULL(1);
-
- SpriteDisplay mDisplay; /**< Display info (like icon) */
- MissileInfo mMissile;
- std::string mName;
- std::string mNameEn;
- std::string mDescription; /**< Short description. */
- std::string mEffect; /**< Description of effects. */
- std::string mUseButton;
- std::string mUseButton2;
- ItemDbTypeT mType; /**< Item type. */
- int mWeight; /**< Weight in grams. */
- int mView; /**< Item ID of how this item looks. */
- int mId; /**< Item ID */
- bool mIsRemoveSprites;
- // sprite, <itemfrom, itemto> [direction]
- SpriteToItemMap *mSpriteToItemReplaceMap[10];
-
- STD_VECTOR<SpriteToItemMap*> mSpriteToItemReplaceList;
-
- // Equipment related members.
- /** Attack type, in case of weapon.
- * See SpriteAction in spritedef.h for more info.
- * Attack action sub-types (bow, sword, ...) are defined in items.xml.
- */
- std::string mAttackAction;
- std::string mSkyAttackAction;
- std::string mWaterAttackAction;
- std::string mRideAttackAction;
- int mAttackRange; /**< Attack range, will be zero if non weapon. */
-
- // Particle to be shown when weapon attacks
- std::string mMissileParticle;
-
- /** Maps gender to sprite filenames. */
- std::map <int, std::string> mAnimationFiles;
-
- /** Stores the names of sounds to be played at certain event. */
- std::map <ItemSoundEvent::Type, SoundInfoVect> mSounds;
- std::map <int, int> mTags;
- const std::map <ItemColor, ItemColorData> *mColorsList;
- const std::map <ItemColor, ItemColorData> *mIconColorsList;
- STD_VECTOR<ItemMenuItem> mInventoryMenu;
- STD_VECTOR<ItemMenuItem> mStorageMenu;
- STD_VECTOR<ItemMenuItem> mCartMenu;
- std::string mColorsListName;
- std::string mIconColorsListName;
- ItemColor mCardColor;
- int mHitEffectId;
- int mCriticalHitEffectId;
- int mMissEffectId;
- int maxFloorOffsetX;
- int maxFloorOffsetY;
- CursorT mPickupCursor;
- bool mProtected;
-};
-
-#endif // RESOURCES_ITEMINFO_H
diff --git a/src/resources/itemmenuitem.h b/src/resources/itemmenuitem.h
deleted file mode 100644
index 0d7dd2950..000000000
--- a/src/resources/itemmenuitem.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEMMENUITEM_H
-#define RESOURCES_ITEMMENUITEM_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct ItemMenuItem final
-{
- ItemMenuItem(const std::string &name01,
- const std::string &name02,
- const std::string &command01,
- const std::string &command02) :
- name1(name01),
- name2(name02),
- command1(command01),
- command2(command02)
- {
- }
-
- A_DEFAULT_COPY(ItemMenuItem)
-
- std::string name1;
- std::string name2;
- std::string command1;
- std::string command2;
-};
-
-#endif // RESOURCES_ITEMMENUITEM_H
diff --git a/src/resources/itemtypemap.h b/src/resources/itemtypemap.h
deleted file mode 100644
index 9cf43d017..000000000
--- a/src/resources/itemtypemap.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEMTYPEMAP_H
-#define RESOURCES_ITEMTYPEMAP_H
-
-#include "enums/resources/item/itemdbtype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct ItemTypeMap final
-{
- A_DEFAULT_COPY(ItemTypeMap)
-
- std::string name;
- ItemDbTypeT type;
- std::string useButton;
- std::string useButton2;
-};
-
-#endif // RESOURCES_ITEMTYPEMAP_H
diff --git a/src/resources/itemtypemapdata.h b/src/resources/itemtypemapdata.h
deleted file mode 100644
index 5f0bd985c..000000000
--- a/src/resources/itemtypemapdata.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_ITEMTYPEMAPDATA_H
-#define RESOURCES_ITEMTYPEMAPDATA_H
-
-#include "utils/gettext.h"
-
-#include "resources/itemtypemap.h"
-
-#include "localconsts.h"
-
-ItemTypeMap itemTypeMap[] =
-{
- {"generic", ItemDbType::UNUSABLE,
- std::string(), std::string()
- },
- {"other", ItemDbType::UNUSABLE,
- // TRANSLATORS: inventory button
- N_("Use"), N_("Use")
- },
- {"usable", ItemDbType::USABLE,
- // TRANSLATORS: inventory button
- N_("Use"), N_("Use")
- },
- {"equip-1hand", ItemDbType::EQUIPMENT_ONE_HAND_WEAPON,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-2hand", ItemDbType::EQUIPMENT_TWO_HANDS_WEAPON,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-torso", ItemDbType::EQUIPMENT_TORSO,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-arms", ItemDbType::EQUIPMENT_ARMS,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-head", ItemDbType::EQUIPMENT_HEAD,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-legs", ItemDbType::EQUIPMENT_LEGS,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-shield", ItemDbType::EQUIPMENT_SHIELD,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-ring", ItemDbType::EQUIPMENT_RING,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-charm", ItemDbType::EQUIPMENT_CHARM,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-necklace", ItemDbType::EQUIPMENT_NECKLACE,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-neck", ItemDbType::EQUIPMENT_NECKLACE,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-feet", ItemDbType::EQUIPMENT_FEET,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"equip-ammo", ItemDbType::EQUIPMENT_AMMO,
- // TRANSLATORS: inventory button
- N_("Equip"), N_("Unequip")
- },
- {"card", ItemDbType::CARD,
- // TRANSLATORS: inventory button
- N_("Insert"), std::string()
- },
- {"racesprite", ItemDbType::SPRITE_RACE,
- std::string(), std::string()
- },
- {"hairsprite", ItemDbType::SPRITE_HAIR,
- std::string(), std::string()
- }
-};
-
-#endif // RESOURCES_ITEMTYPEMAPDATA_H
diff --git a/src/resources/loaders/atlasloader.cpp b/src/resources/loaders/atlasloader.cpp
deleted file mode 100644
index 9f7b4ab09..000000000
--- a/src/resources/loaders/atlasloader.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "resources/atlas/atlasmanager.h"
-#include "resources/atlas/atlasresource.h"
-
-#include "resources/loaders/atlasloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-struct AtlasLoader final
-{
- A_DEFAULT_COPY(AtlasLoader)
-
- const std::string name;
- const StringVect *const files;
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const AtlasLoader *const rl = static_cast<const AtlasLoader *>(v);
- AtlasResource *const resource = AtlasManager::loadTextureAtlas(
- rl->name, *rl->files);
- if (resource == nullptr)
- reportAlways("Atlas creation error: %s", rl->name.c_str());
- return resource;
- }
-};
-
-Resource *Loader::getAtlas(const std::string &name,
- const StringVect &files)
-{
- AtlasLoader rl = { name, &files };
- return ResourceManager::get("atlas_" + name, AtlasLoader::load, &rl);
-}
-
-#endif // USE_OPENGL
diff --git a/src/resources/loaders/atlasloader.h b/src/resources/loaders/atlasloader.h
deleted file mode 100644
index 34aec22a8..000000000
--- a/src/resources/loaders/atlasloader.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_ATLASLOADER_H
-#define RESOURCES_LOADERS_ATLASLOADER_H
-#ifdef USE_OPENGL
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-class Resource;
-
-namespace Loader
-{
- Resource *getAtlas(const std::string &name,
- const StringVect &files) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // USE_OPENGL
-#endif // RESOURCES_LOADERS_ATLASLOADER_H
diff --git a/src/resources/loaders/emptyatlasloader.cpp b/src/resources/loaders/emptyatlasloader.cpp
deleted file mode 100644
index 3138c821b..000000000
--- a/src/resources/loaders/emptyatlasloader.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "resources/atlas/atlasmanager.h"
-#include "resources/atlas/atlasresource.h"
-
-#include "resources/loaders/emptyatlasloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-struct EmptyAtlasLoader final
-{
- A_DEFAULT_COPY(EmptyAtlasLoader)
-
- const std::string name;
- const StringVect *const files;
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const EmptyAtlasLoader *const rl =
- static_cast<const EmptyAtlasLoader *>(v);
- AtlasResource *const resource = AtlasManager::loadEmptyAtlas(
- rl->name, *rl->files);
- if (resource == nullptr)
- reportAlways("Empty atlas creation error: %s", rl->name.c_str());
- return resource;
- }
-};
-
-Resource *Loader::getEmptyAtlas(const std::string &name,
- const StringVect &files)
-{
- EmptyAtlasLoader rl = { name, &files };
- return ResourceManager::get("atlas_" + name, EmptyAtlasLoader::load, &rl);
-}
-
-#endif // USE_OPENGL
diff --git a/src/resources/loaders/emptyatlasloader.h b/src/resources/loaders/emptyatlasloader.h
deleted file mode 100644
index 8a731f8b6..000000000
--- a/src/resources/loaders/emptyatlasloader.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_EMPTYATLASLOADER_H
-#define RESOURCES_LOADERS_EMPTYATLASLOADER_H
-#ifdef USE_OPENGL
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-class Resource;
-
-namespace Loader
-{
- Resource *getEmptyAtlas(const std::string &name,
- const StringVect &files) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // USE_OPENGL
-#endif // RESOURCES_LOADERS_EMPTYATLASLOADER_H
diff --git a/src/resources/loaders/imageloader.cpp b/src/resources/loaders/imageloader.cpp
deleted file mode 100644
index c5635ef14..000000000
--- a/src/resources/loaders/imageloader.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/imagehelper.h"
-
-#include "fs/virtfs/rwops.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/dye/dye.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-namespace
-{
- struct DyedImageLoader final
- {
- A_DEFAULT_COPY(DyedImageLoader)
-
- std::string path;
- static Resource *load(const void *const v)
- {
- BLOCK_START("DyedImageLoader::load")
- if (v == nullptr)
- {
- BLOCK_END("DyedImageLoader::load")
- return nullptr;
- }
-
- const DyedImageLoader *const rl
- = static_cast<const DyedImageLoader *>(v);
-
- std::string path1 = rl->path;
- const size_t p = path1.find('|');
- Dye *d = nullptr;
- if (p != std::string::npos)
- {
- d = new Dye(path1.substr(p + 1));
- path1 = path1.substr(0, p);
- }
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(path1);
- if (rw == nullptr)
- {
- delete d;
- reportAlways("Image loading error: %s", path1.c_str());
- BLOCK_END("DyedImageLoader::load")
- return nullptr;
- }
- Resource *const res = d != nullptr ? imageHelper->load(rw, *d)
- : imageHelper->load(rw);
- delete d;
- if (res == nullptr)
- reportAlways("Image loading error: %s", path1.c_str());
- BLOCK_END("DyedImageLoader::load")
- return res;
- }
- };
-} // namespace
-
-Image *Loader::getImage(const std::string &idPath)
-{
- DyedImageLoader rl = { idPath };
- return static_cast<Image*>(ResourceManager::get(idPath,
- DyedImageLoader::load, &rl));
-}
diff --git a/src/resources/loaders/imageloader.h b/src/resources/loaders/imageloader.h
deleted file mode 100644
index 0cac7d431..000000000
--- a/src/resources/loaders/imageloader.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_IMAGELOADER_H
-#define RESOURCES_LOADERS_IMAGELOADER_H
-
-#include "localconsts.h"
-
-#include <string>
-
-class Image;
-
-namespace Loader
-{
- /**
- * Convenience wrapper around ResourceManager::get for loading
- * images.
- */
- Image *getImage(const std::string &idPath) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // RESOURCES_LOADERS_IMAGELOADER_H
diff --git a/src/resources/loaders/imagesetloader.cpp b/src/resources/loaders/imagesetloader.cpp
deleted file mode 100644
index 63b56d1fe..000000000
--- a/src/resources/loaders/imagesetloader.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/imageset.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-#include "resources/loaders/imagesetloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/checkutils.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-struct ImageSetLoader final
-{
- const std::string path;
- const int w;
- const int h;
-
- A_DEFAULT_COPY(ImageSetLoader)
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const ImageSetLoader *const
- rl = static_cast<const ImageSetLoader *>(v);
-
- Image *const img = Loader::getImage(rl->path);
- if (img == nullptr)
- {
- reportAlways("Image loading error: %s", rl->path.c_str());
- return nullptr;
- }
- ImageSet *const res = new ImageSet(img, rl->w, rl->h);
- img->decRef();
- return res;
- }
-};
-
-ImageSet *Loader::getImageSet(const std::string &imagePath,
- const int w,
- const int h)
-{
- ImageSetLoader rl = { imagePath, w, h };
- const std::string str = std::string(
- imagePath).append(
- "[").append(toString(
- w)).append(
- "x").append(toString(
- h)).append(
- "]");
- return static_cast<ImageSet*>(ResourceManager::get(str,
- ImageSetLoader::load, &rl));
-}
diff --git a/src/resources/loaders/imagesetloader.h b/src/resources/loaders/imagesetloader.h
deleted file mode 100644
index 87e8215f8..000000000
--- a/src/resources/loaders/imagesetloader.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_IMAGESETLOADER_H
-#define RESOURCES_LOADERS_IMAGESETLOADER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class ImageSet;
-
-namespace Loader
-{
- /**
- * Creates a image set based on the image referenced by the given
- * path and the supplied sprite sizes
- */
- ImageSet *getImageSet(const std::string &imagePath,
- const int w,
- const int h) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // RESOURCES_LOADERS_IMAGESETLOADER_H
diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp
deleted file mode 100644
index 7ac151c12..000000000
--- a/src/resources/loaders/musicloader.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/sdlmusic.h"
-
-#include "fs/virtfs/rwops.h"
-
-#include "resources/loaders/musicloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-namespace
-{
- struct ResourceLoader final
- {
- A_DEFAULT_COPY(ResourceLoader)
-
- const std::string path;
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
- const ResourceLoader *const
- rl = static_cast<const ResourceLoader *>(v);
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(rl->path);
- if (rw == nullptr)
- {
- reportAlways("Error loading resource: %s",
- rl->path.c_str());
- return nullptr;
- }
-#ifdef USE_SDL2
- if (Mix_Music *const music = Mix_LoadMUSType_RW(rw, MUS_OGG, 1))
- {
- return new SDLMusic(music, nullptr, rl->path);
- }
-#else // USE_SDL2
-
- // Mix_LoadMUSType_RW was added without version changed in SDL1.2 :(
- if (Mix_Music *const music = Mix_LoadMUS_RW(rw))
- {
- return new SDLMusic(music, rw, rl->path);
- }
-#endif // USE_SDL2
-
- logger->log("Error, failed to load music: %s", SDL_GetError());
- return nullptr;
- }
- };
-} // namespace
-
-SDLMusic *Loader::getMusic(const std::string &idPath)
-{
- ResourceLoader rl = { idPath };
- return static_cast<SDLMusic*>(ResourceManager::get(
- "music_" + idPath, ResourceLoader::load, &rl));
-}
diff --git a/src/resources/loaders/musicloader.h b/src/resources/loaders/musicloader.h
deleted file mode 100644
index aab14e3da..000000000
--- a/src/resources/loaders/musicloader.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RESOURCEMANAGER_MUSICLOADER_H
-#define RESOURCES_RESOURCEMANAGER_MUSICLOADER_H
-
-#include "localconsts.h"
-
-#include <string>
-
-class SDLMusic;
-
-namespace Loader
-{
- /**
- * Convenience wrapper around ResourceManager::get for loading
- * songs.
- */
- SDLMusic *getMusic(const std::string &idPath) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // RESOURCES_RESOURCEMANAGER_MUSICLOADER_H
diff --git a/src/resources/loaders/rescaledloader.cpp b/src/resources/loaders/rescaledloader.cpp
deleted file mode 100644
index e69814d27..000000000
--- a/src/resources/loaders/rescaledloader.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/rescaledloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/checkutils.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace
-{
- struct RescaledLoader final
- {
- A_DEFAULT_COPY(RescaledLoader)
-
- const Image *const image;
- const int width;
- const int height;
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
- const RescaledLoader *const rl
- = static_cast<const RescaledLoader *>(v);
- if (rl->image == nullptr)
- return nullptr;
- Image *const rescaled = rl->image->SDLgetScaledImage(
- rl->width, rl->height);
- if (rescaled == nullptr)
- {
- reportAlways("Rescale image failed: %s",
- rl->image->mIdPath.c_str());
- return nullptr;
- }
- return rescaled;
- }
- };
-} // namespace
-
-Image *Loader::getRescaled(const Image *const image,
- const int width,
- const int height)
-{
- if (image == nullptr)
- return nullptr;
-
- const std::string idPath = image->mIdPath + strprintf(
- "_rescaled%dx%d", width, height);
- const RescaledLoader rl = { image, width, height };
- return static_cast<Image *>(
- ResourceManager::get(idPath, RescaledLoader::load, &rl));
-}
diff --git a/src/resources/loaders/rescaledloader.h b/src/resources/loaders/rescaledloader.h
deleted file mode 100644
index 08960f530..000000000
--- a/src/resources/loaders/rescaledloader.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_RESCALEDLOADER_H
-#define RESOURCES_LOADERS_RESCALEDLOADER_H
-
-#include "localconsts.h"
-
-class Image;
-
-namespace Loader
-{
- Image *getRescaled(const Image *const image,
- const int width,
- const int height) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // RESOURCES_LOADERS_RESCALEDLOADER_H
diff --git a/src/resources/loaders/shaderloader.cpp b/src/resources/loaders/shaderloader.cpp
deleted file mode 100644
index 550be0a75..000000000
--- a/src/resources/loaders/shaderloader.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "utils/checkutils.h"
-
-#include "render/shaders/shader.h"
-#include "render/shaders/shadersmanager.h"
-
-#include "resources/loaders/shaderloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-namespace
-{
- struct ShaderLoader final
- {
- A_DEFAULT_COPY(ShaderLoader)
-
- const std::string name;
- const unsigned int type;
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const ShaderLoader *const rl
- = static_cast<const ShaderLoader *>(v);
- Shader *const resource = shaders.createShader(rl->type, rl->name);
- if (resource == nullptr)
- reportAlways("Shader creation error: %s", rl->name.c_str());
- return resource;
- }
- };
-} // namespace
-
-Resource *Loader::getShader(const unsigned int type,
- const std::string &name)
-{
- ShaderLoader rl = { name, type };
- return ResourceManager::get("shader_" + name, ShaderLoader::load, &rl);
-}
-
-#endif // USE_OPENGL
diff --git a/src/resources/loaders/shaderloader.h b/src/resources/loaders/shaderloader.h
deleted file mode 100644
index 6331f2aef..000000000
--- a/src/resources/loaders/shaderloader.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_SHADERLOADER_H
-#define RESOURCES_LOADERS_SHADERLOADER_H
-
-#ifdef USE_OPENGL
-
-#include <string>
-
-#include "localconsts.h"
-
-class Resource;
-
-namespace Loader
-{
- Resource *getShader(const unsigned int type,
- const std::string &name) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // USE_OPENGL
-#endif // RESOURCES_LOADERS_SHADERLOADER_H
diff --git a/src/resources/loaders/shaderprogramloader.cpp b/src/resources/loaders/shaderprogramloader.cpp
deleted file mode 100644
index fe4a5cf50..000000000
--- a/src/resources/loaders/shaderprogramloader.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "utils/checkutils.h"
-
-#include "render/shaders/shaderprogram.h"
-#include "render/shaders/shadersmanager.h"
-
-#include "resources/loaders/shaderprogramloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-namespace
-{
- struct ShaderProgramLoader final
- {
- A_DEFAULT_COPY(ShaderProgramLoader)
-
- const std::string vertex;
- const std::string fragment;
- const bool isNewShader;
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const ShaderProgramLoader *const rl
- = static_cast<const ShaderProgramLoader *>(v);
- ShaderProgram *const resource = shaders.createProgram(
- rl->vertex,
- rl->fragment,
- rl->isNewShader);
- if (resource == nullptr)
- reportAlways("Shader program creation error");
- return resource;
- }
- };
-} // namespace
-
-Resource *Loader::getShaderProgram(const std::string &vertex,
- const std::string &fragment,
- const bool isNewShader)
-{
- ShaderProgramLoader rl = { vertex, fragment, isNewShader };
- return ResourceManager::get("program_" + vertex + " + " + fragment,
- ShaderProgramLoader::load, &rl);
-}
-
-#endif // USE_OPENGL
diff --git a/src/resources/loaders/shaderprogramloader.h b/src/resources/loaders/shaderprogramloader.h
deleted file mode 100644
index 3554456c8..000000000
--- a/src/resources/loaders/shaderprogramloader.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_SHADERPROGRAMLOADER_H
-#define RESOURCES_LOADERS_SHADERPROGRAMLOADER_H
-
-#ifdef USE_OPENGL
-
-#include <string>
-
-#include "localconsts.h"
-
-class Resource;
-
-namespace Loader
-{
- Resource *getShaderProgram(const std::string &vertex,
- const std::string &fragment,
- const bool isNewShader) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // USE_OPENGL
-#endif // RESOURCES_LOADERS_SHADERPROGRAMLOADER_H
diff --git a/src/resources/loaders/soundloader.cpp b/src/resources/loaders/soundloader.cpp
deleted file mode 100644
index 879bc0cb1..000000000
--- a/src/resources/loaders/soundloader.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/soundeffect.h"
-
-#include "fs/virtfs/rwops.h"
-
-#include "resources/loaders/soundloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-namespace
-{
- struct ResourceLoader final
- {
- A_DEFAULT_COPY(ResourceLoader)
-
- const std::string path;
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
- const ResourceLoader *const
- rl = static_cast<const ResourceLoader *>(v);
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(rl->path);
- if (rw == nullptr)
- {
- reportAlways("Error loading resource: %s",
- rl->path.c_str());
- return nullptr;
- }
- // Load the music data and free the RWops structure
- Mix_Chunk *const tmpSoundEffect = Mix_LoadWAV_RW(rw, 1);
-
- if (tmpSoundEffect != nullptr)
- {
- return new SoundEffect(tmpSoundEffect, rl->path);
- }
- reportAlways("Error, failed to load sound effect: %s",
- SDL_GetError());
- return nullptr;
- }
- };
-} // namespace
-
-SoundEffect *Loader::getSoundEffect(const std::string &idPath)
-{
- ResourceLoader rl = { idPath };
- return static_cast<SoundEffect*>(ResourceManager::get(
- "sound_" + idPath, ResourceLoader::load, &rl));
-}
diff --git a/src/resources/loaders/soundloader.h b/src/resources/loaders/soundloader.h
deleted file mode 100644
index cd05d46c1..000000000
--- a/src/resources/loaders/soundloader.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RESOURCEMANAGER_SOUNDLOADER_H
-#define RESOURCES_RESOURCEMANAGER_SOUNDLOADER_H
-
-#include "localconsts.h"
-
-#include <string>
-
-class SoundEffect;
-
-namespace Loader
-{
- /**
- * Convenience wrapper around ResourceManager::get for loading
- * samples.
- */
- SoundEffect *getSoundEffect(const std::string &idPath) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // RESOURCES_RESOURCEMANAGER_SOUNDLOADER_H
diff --git a/src/resources/loaders/spritedefloader.cpp b/src/resources/loaders/spritedefloader.cpp
deleted file mode 100644
index 2e91d759b..000000000
--- a/src/resources/loaders/spritedefloader.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "settings.h"
-
-#include "resources/loaders/spritedefloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sprite/spritedef.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace
-{
- struct SpriteDefLoader final
- {
- A_DEFAULT_COPY(SpriteDefLoader)
-
- const std::string path;
- const int variant;
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const SpriteDefLoader *const
- rl = static_cast<const SpriteDefLoader *>(v);
- return SpriteDef::load(rl->path,
- rl->variant,
- settings.uselonglivesprites);
- }
- };
-} // namespace
-
-SpriteDef *Loader::getSprite(const std::string &path,
- const int variant)
-{
- SpriteDefLoader rl = { path, variant};
- const std::string str = std::string(
- "sprite_").append(
- path).append(
- "[").append(toString(
- variant).append(
- "]"));
- return static_cast<SpriteDef*>(ResourceManager::get(str,
- SpriteDefLoader::load, &rl));
-}
diff --git a/src/resources/loaders/spritedefloader.h b/src/resources/loaders/spritedefloader.h
deleted file mode 100644
index aec0db818..000000000
--- a/src/resources/loaders/spritedefloader.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_SPRITEDEFLOADER_H
-#define RESOURCES_LOADERS_SPRITEDEFLOADER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class SpriteDef;
-
-namespace Loader
-{
- /**
- * Creates a sprite definition based on a given path and the supplied
- * variant.
- */
- SpriteDef *getSprite(const std::string &path,
- const int variant = 0) A_WARN_UNUSED;
-
-} // namespace Loader
-
-#endif // RESOURCES_LOADERS_SPRITEDEFLOADER_H
diff --git a/src/resources/loaders/subimageloader.cpp b/src/resources/loaders/subimageloader.cpp
deleted file mode 100644
index a4ccc2346..000000000
--- a/src/resources/loaders/subimageloader.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/subimageloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/checkutils.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace
-{
- struct SubImageLoader final
- {
- A_DEFAULT_COPY(SubImageLoader)
-
- Image *const parent;
- const int x;
- const int y;
- const int width;
- const int height;
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const SubImageLoader *const
- rl = static_cast<const SubImageLoader *>(v);
- if (rl->parent == nullptr)
- return nullptr;
-
- Image *const res = rl->parent->getSubImage(rl->x, rl->y,
- rl->width, rl->height);
- if (res == nullptr)
- {
- reportAlways("SubImage loading error: %s",
- rl->parent->mSource.c_str());
- }
- return res;
- }
- };
-} // namespace
-
-Image *Loader::getSubImage(Image *const parent,
- const int x,
- const int y,
- const int width,
- const int height)
-{
- if (parent == nullptr)
- return nullptr;
-
- const SubImageLoader rl = { parent, x, y, width, height};
-
- const std::string str = std::string(parent->mIdPath).append(
- ",[").append(
- toString(x)).append(
- ",").append(
- toString(y)).append(
- ",").append(
- toString(width)).append(
- "x").append(
- toString(height)).append(
- "]");
- return static_cast<Image*>(ResourceManager::get(str,
- SubImageLoader::load, &rl));
-}
diff --git a/src/resources/loaders/subimageloader.h b/src/resources/loaders/subimageloader.h
deleted file mode 100644
index ba0d3fde2..000000000
--- a/src/resources/loaders/subimageloader.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RESOURCEMANAGER_SUBIMAGELOADER_H
-#define RESOURCES_RESOURCEMANAGER_SUBIMAGELOADER_H
-
-#include "localconsts.h"
-
-class Image;
-
-namespace Loader
-{
- Image *getSubImage(Image *const parent,
- const int x,
- const int y,
- const int width,
- const int height) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // RESOURCES_RESOURCEMANAGER_SUBIMAGELOADER_H
diff --git a/src/resources/loaders/subimagesetloader.cpp b/src/resources/loaders/subimagesetloader.cpp
deleted file mode 100644
index ef47b164d..000000000
--- a/src/resources/loaders/subimagesetloader.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/imageset.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/subimagesetloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace
-{
- struct SubImageSetLoader final
- {
- A_DEFAULT_COPY(SubImageSetLoader)
-
- Image *const parent;
- int width;
- int height;
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const SubImageSetLoader *const
- rl = static_cast<const SubImageSetLoader *>(v);
-
- if (rl->parent == nullptr)
- return nullptr;
- ImageSet *const res = new ImageSet(rl->parent,
- rl->width, rl->height);
- return res;
- }
- };
-} // namespace
-
-ImageSet *Loader::getSubImageSet(Image *const parent,
- const int width,
- const int height)
-{
- if (parent == nullptr)
- return nullptr;
-
- const SubImageSetLoader rl = { parent, width, height };
- std::string str = std::string(
- parent->mIdPath).append(
- ", set[").append(toString(
- width)).append(
- "x").append(toString(
- height)).append(
- "]");
- return static_cast<ImageSet*>(ResourceManager::get(str,
- SubImageSetLoader::load, &rl));
-}
diff --git a/src/resources/loaders/subimagesetloader.h b/src/resources/loaders/subimagesetloader.h
deleted file mode 100644
index 4c441e1cf..000000000
--- a/src/resources/loaders/subimagesetloader.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_SUBIMAGESETLOADER_H
-#define RESOURCES_LOADERS_SUBIMAGESETLOADER_H
-
-#include "localconsts.h"
-
-class Image;
-class ImageSet;
-
-namespace Loader
-{
- ImageSet *getSubImageSet(Image *const parent,
- const int width,
- const int height) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // RESOURCES_LOADERS_SUBIMAGESETLOADER_H
diff --git a/src/resources/loaders/walklayerloader.cpp b/src/resources/loaders/walklayerloader.cpp
deleted file mode 100644
index 16be1e2ce..000000000
--- a/src/resources/loaders/walklayerloader.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "navigationmanager.h"
-
-#include "resources/map/walklayer.h"
-
-#include "resources/loaders/walklayerloader.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-#ifndef DYECMD
-struct WalkLayerLoader final
-{
- A_DEFAULT_COPY(WalkLayerLoader)
-
- const std::string name;
- const Map *const map;
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
-
- const WalkLayerLoader *const rl = static_cast<const
- WalkLayerLoader *>(v);
- Resource *const resource = NavigationManager::loadWalkLayer(rl->map);
- if (resource == nullptr)
- reportAlways("WalkLayer creation error");
- return resource;
- }
-};
-
-WalkLayer *Loader::getWalkLayer(const std::string &name,
- Map *const map)
-{
- WalkLayerLoader rl = {name, map};
- return static_cast<WalkLayer*>(ResourceManager::get("walklayer_" + name,
- WalkLayerLoader::load, &rl));
-}
-#else // DYECMD
-
-WalkLayer *Loader::getWalkLayer(const std::string &name A_UNUSED,
- Map *const map A_UNUSED)
-{
- return nullptr;
-}
-#endif // DYECMD
diff --git a/src/resources/loaders/walklayerloader.h b/src/resources/loaders/walklayerloader.h
deleted file mode 100644
index ef1dcbff7..000000000
--- a/src/resources/loaders/walklayerloader.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_LOADERS_WALKLAYERLOADER_H
-#define RESOURCES_LOADERS_WALKLAYERLOADER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class Map;
-class WalkLayer;
-
-namespace Loader
-{
- WalkLayer *getWalkLayer(const std::string &name,
- Map *const map) A_WARN_UNUSED;
-} // namespace Loader
-
-#endif // RESOURCES_LOADERS_WALKLAYERLOADER_H
diff --git a/src/resources/loaders/xmlloader.cpp b/src/resources/loaders/xmlloader.cpp
deleted file mode 100644
index 2d06d8128..000000000
--- a/src/resources/loaders/xmlloader.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/loaders/xmlloader.h"
-
-#include "debug.h"
-
-namespace
-{
- struct ResourceLoader final
- {
- A_DEFAULT_COPY(ResourceLoader)
-
- const std::string path;
- const UseVirtFs useResman;
- const SkipError skipError;
-
- static Resource *load(const void *const v)
- {
- if (v == nullptr)
- return nullptr;
- const ResourceLoader *const
- rl = static_cast<const ResourceLoader *>(v);
- return new XML::Document(rl->path,
- rl->useResman,
- rl->skipError);
- }
- };
-
-} // namespace
-
-XML::Document *Loader::getXml(const std::string &idPath,
- const UseVirtFs useResman,
- const SkipError skipError)
-{
- ResourceLoader rl = { idPath, useResman, skipError };
- return static_cast<XML::Document*>(ResourceManager::get(
- "xml_" + idPath, ResourceLoader::load, &rl));
-}
diff --git a/src/resources/loaders/xmlloader.h b/src/resources/loaders/xmlloader.h
deleted file mode 100644
index a52186daa..000000000
--- a/src/resources/loaders/xmlloader.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RESOURCEMANAGER_XMLLOADER_H
-#define RESOURCES_RESOURCEMANAGER_XMLLOADER_H
-
-#include "utils/xml.h"
-
-#include "localconsts.h"
-
-namespace Loader
-{
- XML::Document *getXml(const std::string &idPath,
- const UseVirtFs useResman,
- const SkipError skipError) A_WARN_UNUSED;
-
-} // namespace Loader
-
-#endif // RESOURCES_RESOURCEMANAGER_XMLLOADER_H
diff --git a/src/resources/mailqueue.h b/src/resources/mailqueue.h
deleted file mode 100644
index 52c264ea1..000000000
--- a/src/resources/mailqueue.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAILQUEUE_H
-#define RESOURCES_MAILQUEUE_H
-
-#include "enums/resources/mailqueuetype.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-struct MailQueue final
-{
- MailQueue() :
- to(),
- title(),
- body(),
- money(0),
- type(MailQueueType::Unknown)
- { }
-
- A_DELETE_COPY(MailQueue)
-
- std::string to;
- std::string title;
- std::string body;
- int64_t money;
- MailQueueTypeT type;
-};
-
-#endif // RESOURCES_MAILQUEUE_H
diff --git a/src/resources/map/location.h b/src/resources/map/location.h
deleted file mode 100644
index 44d2619a7..000000000
--- a/src/resources/map/location.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_LOCATION_H
-#define RESOURCES_MAP_LOCATION_H
-
-#include "resources/map/metatile.h"
-
-#include "localconsts.h"
-
-/**
- * A location on a tile map. Used for pathfinding, open list.
- */
-struct Location final
-{
- /**
- * Constructor.
- */
- Location(const int px,
- const int py,
- MetaTile *const ptile) :
- x(px),
- y(py),
- tile(ptile)
- {}
-
- A_DEFAULT_COPY(Location)
-
- /**
- * Comparison operator.
- */
- bool operator< (const Location &loc) const
- {
- return tile->Fcost > loc.tile->Fcost;
- }
-
- int x, y;
- MetaTile *tile;
-};
-
-#endif // RESOURCES_MAP_LOCATION_H
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
deleted file mode 100644
index 6a70048e8..000000000
--- a/src/resources/map/map.cpp
+++ /dev/null
@@ -1,1786 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/map/map.h"
-
-#include "configuration.h"
-#include "render/graphics.h"
-#include "notifymanager.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "enums/resources/map/blockmask.h"
-#include "enums/resources/map/mapitemtype.h"
-
-#include "fs/mkdir.h"
-
-#include "gui/userpalette.h"
-
-#include "particle/particle.h"
-
-#include "resources/ambientlayer.h"
-
-#include "resources/image/subimage.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "resources/map/location.h"
-#include "resources/map/mapheights.h"
-#include "resources/map/mapobjectlist.h"
-#include "resources/map/maplayer.h"
-#include "resources/map/mapitem.h"
-#include "resources/map/objectslayer.h"
-#include "resources/map/speciallayer.h"
-#include "resources/map/tileanimation.h"
-#include "resources/map/tileset.h"
-#include "resources/map/walklayer.h"
-
-
-#ifdef USE_OPENGL
-#include "render/renderers.h"
-#endif // USE_OPENGL
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/timer.h"
-
-#include <queue>
-
-#include <sys/stat.h>
-
-#include <climits>
-
-#include "debug.h"
-
-class ActorFunctuator final
-{
- public:
- A_DEFAULT_COPY(ActorFunctuator)
-
- bool operator()(const Actor *const a,
- const Actor *const b) const
- {
- if ((a == nullptr) || (b == nullptr))
- return false;
- return a->getSortPixelY() < b->getSortPixelY();
- }
-} actorCompare;
-
-Map::Map(const std::string &name,
- const int width,
- const int height,
- const int tileWidth,
- const int tileHeight) :
- Properties(),
- mWidth(width), mHeight(height),
- mTileWidth(tileWidth), mTileHeight(tileHeight),
- mMaxTileHeight(height),
- mMetaTiles(new MetaTile[mWidth * mHeight]),
- mWalkLayer(nullptr),
- mLayers(),
- mDrawUnderLayers(),
- mDrawOverLayers(),
- mTilesets(),
- mActors(),
- mHasWarps(false),
- mDrawLayersFlags(MapType::NORMAL),
- mOnClosedList(1),
- mOnOpenList(2),
- mBackgrounds(),
- mForegrounds(),
- mLastAScrollX(0.0F),
- mLastAScrollY(0.0F),
- mParticleEffects(),
- mMapPortals(),
- mTileAnimations(),
- mName(name),
- mOverlayDetail(config.getIntValue("OverlayDetail")),
- mOpacity(config.getFloatValue("guialpha")),
-#ifdef USE_OPENGL
- mOpenGL(intToRenderType(config.getIntValue("opengl"))),
-#else // USE_OPENGL
- mOpenGL(RENDER_SOFTWARE),
-#endif // USE_OPENGL
- mPvp(0),
- mTilesetsIndexed(false),
- mIndexedTilesets(nullptr),
- mIndexedTilesetsSize(0),
- mActorFixX(0),
- mActorFixY(0),
- mVersion(0),
- mSpecialLayer(new SpecialLayer("special layer", width, height)),
- mTempLayer(new SpecialLayer("temp layer", width, height)),
- mObjects(new ObjectsLayer(width, height)),
- mFringeLayer(nullptr),
- mLastX(-1),
- mLastY(-1),
- mLastScrollX(-1),
- mLastScrollY(-1),
- mDrawX(-1),
- mDrawY(-1),
- mDrawScrollX(-1),
- mDrawScrollY(-1),
- mMask(1),
- mAtlas(nullptr),
- mHeights(nullptr),
- mRedrawMap(true),
- mBeingOpacity(false),
-#ifdef USE_OPENGL
- mCachedDraw(mOpenGL == RENDER_NORMAL_OPENGL ||
- mOpenGL == RENDER_GLES_OPENGL ||
- mOpenGL == RENDER_GLES2_OPENGL ||
- mOpenGL == RENDER_MODERN_OPENGL),
-#else // USE_OPENGL
- mCachedDraw(false),
-#endif // USE_OPENGL
- mCustom(false),
- mDrawOnlyFringe(false)
-{
- config.addListener("OverlayDetail", this);
- config.addListener("guialpha", this);
- config.addListener("beingopacity", this);
-
- if (mOpacity != 1.0F)
- mBeingOpacity = config.getBoolValue("beingopacity");
- else
- mBeingOpacity = false;
-}
-
-Map::~Map()
-{
- config.removeListeners(this);
- CHECKLISTENERS
-
- if (mWalkLayer != nullptr)
- {
- mWalkLayer->decRef();
- mWalkLayer = nullptr;
- }
- mFringeLayer = nullptr;
- delete_all(mLayers);
- delete_all(mTilesets);
- delete_all(mForegrounds);
- delete_all(mBackgrounds);
- delete_all(mTileAnimations);
- delete2(mSpecialLayer);
- delete2(mTempLayer);
- delete2(mObjects);
- delete_all(mMapPortals);
- if (mAtlas != nullptr)
- {
- mAtlas->decRef();
- mAtlas = nullptr;
- }
- delete2(mHeights);
- delete [] mMetaTiles;
-}
-
-void Map::optionChanged(const std::string &restrict value) restrict2
-{
- if (value == "OverlayDetail")
- {
- mOverlayDetail = config.getIntValue("OverlayDetail");
- }
- else if (value == "guialpha")
- {
- mOpacity = config.getFloatValue("guialpha");
- if (mOpacity != 1.0F)
- mBeingOpacity = config.getBoolValue("beingopacity");
- else
- mBeingOpacity = false;
- }
- else if (value == "beingopacity")
- {
- if (mOpacity != 1.0F)
- mBeingOpacity = config.getBoolValue("beingopacity");
- else
- mBeingOpacity = false;
- }
-}
-
-void Map::initializeAmbientLayers() restrict2
-{
- // search for "foreground*" or "overlay*" (old term) in map properties
- for (int i = 0; /* terminated by a break */; i++)
- {
- std::string name;
- if (hasProperty(std::string("foreground").append(
- toString(i)).append("image")))
- {
- name = "foreground" + toString(i);
- }
- else if (hasProperty(std::string("overlay").append(
- toString(i)).append("image")))
- {
- name = "overlay" + toString(i);
- }
- else
- {
- break; // the FOR loop
- }
-
- Image *restrict const img = Loader::getImage(
- getProperty(name + "image"));
- if (img != nullptr)
- {
- int mask = atoi(getProperty(name + "mask").c_str());
- if (mask == 0)
- mask = 1;
- const float parallax = getFloatProperty(name + "parallax");
- mForegrounds.push_back(new AmbientLayer(
- name,
- img,
- getFloatProperty(name + "parallaxX", parallax),
- getFloatProperty(name + "parallaxY", parallax),
- getFloatProperty(name + "posX"),
- getFloatProperty(name + "posY"),
- getFloatProperty(name + "scrollX"),
- getFloatProperty(name + "scrollY"),
- getBoolProperty(name + "keepratio"),
- mask));
-
- // The AmbientLayer takes control over the image.
- img->decRef();
- }
- }
-
- // search for "background*" in map properties
- for (int i = 0; hasProperty(std::string("background").append(
- toString(i)).append("image")); i ++)
- {
- const std::string name("background" + toString(i));
- Image *restrict const img = Loader::getImage(
- getProperty(name + "image"));
-
- if (img != nullptr)
- {
- int mask = atoi(getProperty(name + "mask").c_str());
- if (mask == 0)
- mask = 1;
-
- const float parallax = getFloatProperty(name + "parallax");
- mBackgrounds.push_back(new AmbientLayer(
- name,
- img,
- getFloatProperty(name + "parallaxX", parallax),
- getFloatProperty(name + "parallaxY", parallax),
- getFloatProperty(name + "posX"),
- getFloatProperty(name + "posY"),
- getFloatProperty(name + "scrollX"),
- getFloatProperty(name + "scrollY"),
- getBoolProperty(name + "keepratio"),
- mask));
-
- // The AmbientLayer takes control over the image.
- img->decRef();
- }
- }
-}
-
-void Map::addLayer(MapLayer *const layer) restrict2
-{
- mLayers.push_back(layer);
- if (layer->isFringeLayer() && (mFringeLayer == nullptr))
- mFringeLayer = layer;
-}
-
-void Map::addTileset(Tileset *const tileset) restrict2
-{
- mTilesets.push_back(tileset);
- const int height = tileset->getHeight();
- if (height > mMaxTileHeight)
- mMaxTileHeight = height;
-}
-
-void Map::update(const int ticks) restrict2
-{
- // Update animated tiles
- FOR_EACH (TileAnimationMapCIter, iAni, mTileAnimations)
- {
- TileAnimation *restrict const tileAni = iAni->second;
- if ((tileAni != nullptr) && tileAni->update(ticks))
- mRedrawMap = true;
- }
-}
-
-void Map::draw(Graphics *restrict const graphics,
- int scrollX, int scrollY) restrict2
-{
- if (localPlayer == nullptr)
- return;
-
- BLOCK_START("Map::draw")
- // Calculate range of tiles which are on-screen
- const int endPixelY = graphics->mHeight + scrollY + mTileHeight - 1
- + mMaxTileHeight - mTileHeight;
- const int startX = scrollX / mTileWidth - 2;
- const int startY = scrollY / mTileHeight;
- const int endX = (graphics->mWidth + scrollX + mTileWidth - 1)
- / mTileWidth + 1;
- const int endY = endPixelY / mTileHeight + 1;
-
- // Make sure actors are sorted ascending by Y-coordinate
- // so that they overlap correctly
- BLOCK_START("Map::draw sort")
- mActors.sort(actorCompare);
- BLOCK_END("Map::draw sort")
-
- // update scrolling of all ambient layers
- updateAmbientLayers(static_cast<float>(scrollX),
- static_cast<float>(scrollY));
-
- // Draw backgrounds
- drawAmbientLayers(graphics,
- MapLayerPosition::BACKGROUND_LAYERS,
- mOverlayDetail);
-
- if (mDrawLayersFlags == MapType::BLACKWHITE && (userPalette != nullptr))
- {
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::WALKABLE_HIGHLIGHT));
-
- graphics->fillRectangle(Rect(0, 0,
- graphics->mWidth, graphics->mHeight));
- }
-
-#ifdef USE_OPENGL
- int updateFlag = 0;
-
- if (mCachedDraw)
- {
- if (mLastX != startX || mLastY != startY || mLastScrollX != scrollX
- || mLastScrollY != scrollY)
- { // player moving
- mLastX = startX;
- mLastY = startY;
- mLastScrollX = scrollX;
- mLastScrollY = scrollY;
- updateFlag = 2;
- }
- else if (mRedrawMap || startX != mDrawX || startY != mDrawY ||
- scrollX != mDrawScrollX || scrollY != mDrawScrollY)
- { // player mode to new position
- mRedrawMap = false;
- mDrawX = startX;
- mDrawY = startY;
- mDrawScrollX = scrollX;
- mDrawScrollY = scrollY;
- updateFlag = 1;
- }
- }
-#endif // USE_OPENGL
-
- if (mDrawOnlyFringe)
- {
- if (mFringeLayer != nullptr)
- {
- mFringeLayer->setSpecialLayer(mSpecialLayer);
- mFringeLayer->setTempLayer(mTempLayer);
- mFringeLayer->drawFringe(graphics,
- startX, startY,
- endX, endY,
- scrollX, scrollY,
- mActors);
- }
- }
- else
- {
-#ifdef USE_OPENGL
- if (mCachedDraw)
- {
- if (updateFlag != 0)
- {
- FOR_EACH (Layers::iterator, it, mDrawUnderLayers)
- {
- (*it)->updateOGL(graphics,
- startX, startY,
- endX, endY,
- scrollX, scrollY);
- }
- FOR_EACH (Layers::iterator, it, mDrawOverLayers)
- {
- (*it)->updateOGL(graphics,
- startX, startY,
- endX, endY,
- scrollX, scrollY);
- }
- }
-
- FOR_EACH (Layers::iterator, it, mDrawUnderLayers)
- (*it)->drawOGL(graphics);
-
- if (mFringeLayer != nullptr)
- {
- mFringeLayer->setSpecialLayer(mSpecialLayer);
- mFringeLayer->setTempLayer(mTempLayer);
- mFringeLayer->drawFringe(graphics,
- startX, startY,
- endX, endY,
- scrollX, scrollY,
- mActors);
- }
-
- FOR_EACH (Layers::iterator, it, mDrawOverLayers)
- (*it)->drawOGL(graphics);
- }
- else
-#endif // USE_OPENGL
- {
- FOR_EACH (Layers::iterator, it, mDrawUnderLayers)
- {
- (*it)->draw(graphics,
- startX, startY,
- endX, endY,
- scrollX, scrollY);
- }
-
- if (mFringeLayer != nullptr)
- {
- mFringeLayer->setSpecialLayer(mSpecialLayer);
- mFringeLayer->setTempLayer(mTempLayer);
- mFringeLayer->drawFringe(graphics,
- startX, startY,
- endX, endY,
- scrollX, scrollY,
- mActors);
- }
-
- FOR_EACH (Layers::iterator, it, mDrawOverLayers)
- {
- (*it)->draw(graphics, startX, startY,
- endX, endY,
- scrollX, scrollY);
- }
- }
- }
-
- // Don't draw if gui opacity == 1
- if (mBeingOpacity)
- {
- // Draws beings with a lower opacity to make them visible
- // even when covered by a wall or some other elements...
- ActorsCIter ai = mActors.begin();
- const ActorsCIter ai_end = mActors.end();
-
- if (mOpenGL == RENDER_SOFTWARE)
- {
- while (ai != ai_end)
- {
- if (Actor *restrict const actor = *ai)
- {
- const int x = actor->getTileX();
- const int y = actor->getTileY();
- if (x < startX || x > endX || y < startY || y > endY)
- {
- ++ai;
- continue;
- }
- // For now, just draw actors with only one layer.
- if (actor->getNumberOfLayers() == 1)
- {
- actor->setAlpha(0.3F);
- actor->draw(graphics, -scrollX, -scrollY);
- actor->setAlpha(1.0F);
- }
- }
- ++ai;
- }
- }
- else
- {
- while (ai != ai_end)
- {
- if (Actor *const actor = *ai)
- {
- actor->setAlpha(0.3F);
- actor->draw(graphics, -scrollX, -scrollY);
- actor->setAlpha(1.0F);
- }
- ++ai;
- }
- }
- }
-
- drawAmbientLayers(graphics,
- MapLayerPosition::FOREGROUND_LAYERS,
- mOverlayDetail);
- BLOCK_END("Map::draw")
-}
-
-#define fillCollision(collision, color) \
- if (x < endX && mMetaTiles[tilePtr].blockmask & collision)\
- {\
- width = mapTileSize;\
- for (int x2 = tilePtr + 1; x < endX; x2 ++)\
- {\
- if (!(mMetaTiles[x2].blockmask & collision))\
- break;\
- width += mapTileSize;\
- x ++;\
- tilePtr ++;\
- }\
- if (width && userPalette)\
- {\
- graphics->setColor(userPalette->getColorWithAlpha(\
- UserColorId::color));\
- graphics->fillRectangle(Rect(\
- x0 * mTileWidth - scrollX, \
- y * mTileHeight - scrollY, \
- width, mapTileSize));\
- }\
- }\
-
-void Map::drawCollision(Graphics *restrict const graphics,
- const int scrollX,
- const int scrollY,
- const MapTypeT drawFlags) const restrict2
-{
- const int endPixelY = graphics->mHeight + scrollY + mTileHeight - 1;
- int startX = scrollX / mTileWidth;
- int startY = scrollY / mTileHeight;
- int endX = (graphics->mWidth + scrollX + mTileWidth - 1) / mTileWidth;
- int endY = endPixelY / mTileHeight;
-
- if (startX < 0)
- startX = 0;
- if (startY < 0)
- startY = 0;
- if (endX > mWidth)
- endX = mWidth;
- if (endY > mHeight)
- endY = mHeight;
-
- if (drawFlags < MapType::SPECIAL)
- {
- graphics->setColor(userPalette->getColorWithAlpha(UserColorId::NET));
- graphics->drawNet(
- startX * mTileWidth - scrollX,
- startY * mTileHeight - scrollY,
- endX * mTileWidth - scrollX,
- endY * mTileHeight - scrollY,
- mapTileSize, mapTileSize);
- }
-
- for (int y = startY; y < endY; y++)
- {
- const int yWidth = y * mWidth;
- int tilePtr = startX + yWidth;
- for (int x = startX; x < endX; x++, tilePtr++)
- {
- int width = 0;
- const int x0 = x;
-
- fillCollision(BlockMask::WALL, COLLISION_HIGHLIGHT);
- fillCollision(BlockMask::AIR, AIR_COLLISION_HIGHLIGHT);
- fillCollision(BlockMask::WATER, WATER_COLLISION_HIGHLIGHT);
- fillCollision(BlockMask::GROUNDTOP, GROUNDTOP_COLLISION_HIGHLIGHT);
- fillCollision(BlockMask::PLAYERWALL, COLLISION_HIGHLIGHT);
- fillCollision(BlockMask::MONSTERWALL, MONSTER_COLLISION_HIGHLIGHT);
- }
- }
-}
-
-void Map::updateAmbientLayers(const float scrollX,
- const float scrollY) restrict2
-{
- BLOCK_START("Map::updateAmbientLayers")
- static int lastTick = tick_time;
-
- if (mLastAScrollX == 0.0F && mLastAScrollY == 0.0F)
- {
- // First call - initialisation
- mLastAScrollX = scrollX;
- mLastAScrollY = scrollY;
- }
-
- // Update Overlays
- const float dx = scrollX - mLastAScrollX;
- const float dy = scrollY - mLastAScrollY;
- const int timePassed = get_elapsed_time(lastTick);
-
- // need check mask to update or not to update
-
- FOR_EACH (AmbientLayerVectorIter, i, mBackgrounds)
- {
- AmbientLayer *const layer = *i;
- if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
- layer->update(timePassed, dx, dy);
- }
-
- FOR_EACH (AmbientLayerVectorIter, i, mForegrounds)
- {
- AmbientLayer *const layer = *i;
- if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
- layer->update(timePassed, dx, dy);
- }
-
- mLastAScrollX = scrollX;
- mLastAScrollY = scrollY;
- lastTick = tick_time;
- BLOCK_END("Map::updateAmbientLayers")
-}
-
-void Map::drawAmbientLayers(Graphics *restrict const graphics,
- const MapLayerPositionT type,
- const int detail) const restrict2
-{
- BLOCK_START("Map::drawAmbientLayers")
- // Detail 0 = no ambient effects except background image
- if (detail <= 0 && type != MapLayerPosition::BACKGROUND_LAYERS)
- {
- BLOCK_END("Map::drawAmbientLayers")
- return;
- }
-
- // find out which layer list to draw
- const AmbientLayerVector *restrict layers = nullptr;
- switch (type)
- {
- case MapLayerPosition::FOREGROUND_LAYERS:
- layers = &mForegrounds;
- break;
- case MapLayerPosition::BACKGROUND_LAYERS:
- layers = &mBackgrounds;
- break;
- default:
- return;
- }
-
- // Draw overlays
- FOR_EACHP (AmbientLayerVectorCIter, i, layers)
- {
- const AmbientLayer *restrict const layer = *i;
- // need check mask to draw or not to draw
- if ((layer != nullptr) && ((layer->mMask & mMask) != 0))
- (layer)->draw(graphics, graphics->mWidth, graphics->mHeight);
-
- // Detail 1: only one overlay, higher: all overlays
- if (detail == 1)
- break;
- }
- BLOCK_END("Map::drawAmbientLayers")
-}
-
-const Tileset *Map::getTilesetWithGid(const int gid) const restrict2
-{
- if (gid >= 0 && gid < mIndexedTilesetsSize)
- return mIndexedTilesets[gid];
- return nullptr;
-}
-
-void Map::addBlockMask(const int x, const int y,
- const BlockTypeT type) restrict2
-{
- if (type == BlockType::NONE || !contains(x, y))
- return;
-
- const int tileNum = x + y * mWidth;
-
- switch (type)
- {
- case BlockType::WALL:
- mMetaTiles[tileNum].blockmask |= BlockMask::WALL;
- break;
- case BlockType::AIR:
- mMetaTiles[tileNum].blockmask |= BlockMask::AIR;
- break;
- case BlockType::WATER:
- mMetaTiles[tileNum].blockmask |= BlockMask::WATER;
- break;
- case BlockType::GROUND:
- mMetaTiles[tileNum].blockmask |= BlockMask::GROUND;
- break;
- case BlockType::GROUNDTOP:
- mMetaTiles[tileNum].blockmask |= BlockMask::GROUNDTOP;
- break;
- case BlockType::PLAYERWALL:
- mMetaTiles[tileNum].blockmask |= BlockMask::PLAYERWALL;
- break;
- case BlockType::MONSTERWALL:
- mMetaTiles[tileNum].blockmask |= BlockMask::MONSTERWALL;
- break;
- default:
- case BlockType::NONE:
- case BlockType::NB_BLOCKTYPES:
- // Do nothing.
- break;
- }
-}
-
-void Map::setBlockMask(const int x, const int y,
- const BlockTypeT type) restrict2
-{
- if (type == BlockType::NONE || !contains(x, y))
- return;
-
- const int tileNum = x + y * mWidth;
-
- switch (type)
- {
- case BlockType::WALL:
- mMetaTiles[tileNum].blockmask = BlockMask::WALL;
- break;
- case BlockType::AIR:
- mMetaTiles[tileNum].blockmask = BlockMask::AIR;
- break;
- case BlockType::WATER:
- mMetaTiles[tileNum].blockmask = BlockMask::WATER;
- break;
- case BlockType::GROUND:
- mMetaTiles[tileNum].blockmask = BlockMask::GROUND;
- break;
- case BlockType::GROUNDTOP:
- mMetaTiles[tileNum].blockmask = BlockMask::GROUNDTOP;
- break;
- case BlockType::PLAYERWALL:
- mMetaTiles[tileNum].blockmask = BlockMask::PLAYERWALL;
- break;
- case BlockType::MONSTERWALL:
- mMetaTiles[tileNum].blockmask = BlockMask::MONSTERWALL;
- break;
- default:
- case BlockType::NONE:
- case BlockType::NB_BLOCKTYPES:
- // Do nothing.
- break;
- }
-}
-
-bool Map::getWalk(const int x, const int y,
- const unsigned char blockWalkMask) const restrict2
-{
- // You can't walk outside of the map
- if (x < 0 || y < 0 || x >= mWidth || y >= mHeight)
- return false;
-
- // Check if the tile is walkable
- return (mMetaTiles[x + y * mWidth].blockmask & blockWalkMask) == 0;
-}
-
-unsigned char Map::getBlockMask(const int x,
- const int y) const restrict2
-{
- // You can't walk outside of the map
- if (x < 0 || y < 0 || x >= mWidth || y >= mHeight)
- return 0;
-
- // Check if the tile is walkable
- return mMetaTiles[x + y * mWidth].blockmask;
-}
-
-void Map::setWalk(const int x, const int y) restrict2
-{
- addBlockMask(x, y, BlockType::GROUNDTOP);
-}
-
-bool Map::contains(const int x, const int y) const restrict2
-{
- return x >= 0 && y >= 0 && x < mWidth && y < mHeight;
-}
-
-const MetaTile *Map::getMetaTile(const int x, const int y) const restrict2
-{
- return &mMetaTiles[x + y * mWidth];
-}
-
-Actors::iterator Map::addActor(Actor *const actor) restrict2
-{
- mActors.push_front(actor);
-// mSpritesUpdated = true;
- return mActors.begin();
-}
-
-void Map::removeActor(const Actors::iterator &restrict iterator) restrict2
-{
- mActors.erase(iterator);
-// mSpritesUpdated = true;
-}
-
-const std::string Map::getMusicFile() const restrict2
-{
- return getProperty("music");
-}
-
-const std::string Map::getName() const restrict2
-{
- if (hasProperty("name"))
- return getProperty("name");
-
- return getProperty("mapname");
-}
-
-const std::string Map::getFilename() const restrict2
-{
- const std::string fileName = getProperty("_filename");
- const size_t lastSlash = fileName.rfind('/') + 1;
- return fileName.substr(lastSlash, fileName.rfind('.') - lastSlash);
-}
-
-const std::string Map::getGatName() const restrict2
-{
- const std::string fileName = getProperty("_filename");
- const size_t lastSlash = fileName.rfind('/') + 1;
- return fileName.substr(lastSlash,
- fileName.rfind('.') - lastSlash).append(".gat");
-}
-
-Path Map::findPath(const int startX, const int startY,
- const int destX, const int destY,
- const unsigned char blockWalkMask,
- const int maxCost) restrict2
-{
- BLOCK_START("Map::findPath")
- // The basic walking cost of a tile.
- static const int basicCost = 100;
- const int basicCost2 = 100 * 362 / 256;
- const float basicCostF = 100.0 * 362 / 256;
-
- // Path to be built up (empty by default)
- Path path;
-
- if (startX >= mWidth || startY >= mHeight || startX < 0 || startY < 0)
- {
- BLOCK_END("Map::findPath")
- return path;
- }
-
- // Return when destination not walkable
- if (!getWalk(destX, destY, blockWalkMask))
- {
- BLOCK_END("Map::findPath")
- return path;
- }
-
- // Reset starting tile's G cost to 0
- MetaTile *const startTile = &mMetaTiles[startX + startY * mWidth];
- if (startTile == nullptr)
- {
- BLOCK_END("Map::findPath")
- return path;
- }
-
- startTile->Gcost = 0;
-
- // Declare open list, a list with open tiles sorted on F cost
- std::priority_queue<Location> openList;
-
- // Add the start point to the open list
- openList.push(Location(startX, startY, startTile));
-
- bool foundPath = false;
-
- // Keep trying new open tiles until no more tiles to try or target found
- while (!openList.empty() && !foundPath)
- {
- // Take the location with the lowest F cost from the open list.
- const Location curr = openList.top();
- openList.pop();
-
- const MetaTile *const tile = curr.tile;
-
- // If the tile is already on the closed list, this means it has already
- // been processed with a shorter path to the start point (lower G cost)
- if (tile->whichList == mOnClosedList)
- continue;
-
- // Put the current tile on the closed list
- curr.tile->whichList = mOnClosedList;
-
- const int curWidth = curr.y * mWidth;
- const int tileGcost = tile->Gcost;
-
- // Check the adjacent tiles
- for (int dy = -1; dy <= 1; dy++)
- {
- const int y = curr.y + dy;
- if (y < 0 || y >= mHeight)
- continue;
-
- const int yWidth = y * mWidth;
- const int dy1 = std::abs(y - destY);
-
- for (int dx = -1; dx <= 1; dx++)
- {
- // Calculate location of tile to check
- const int x = curr.x + dx;
-
- // Skip if if we're checking the same tile we're leaving from,
- // or if the new location falls outside of the map boundaries
- if ((dx == 0 && dy == 0) || x < 0 || x >= mWidth)
- continue;
-
- MetaTile *const newTile = &mMetaTiles[x + yWidth];
-
- // Skip if the tile is on the closed list or is not walkable
- // unless its the destination tile
- // +++ probably here "newTile->blockmask & BlockMask::WALL"
- // can be removed. It left here only for protect from
- // walk on wall in any case
- if (newTile->whichList == mOnClosedList ||
- (((newTile->blockmask & blockWalkMask) != 0)
- && !(x == destX && y == destY))
- || ((newTile->blockmask & BlockMask::WALL) != 0))
- {
- continue;
- }
-
- // When taking a diagonal step, verify that we can skip the
- // corner.
- if (dx != 0 && dy != 0)
- {
- const MetaTile *const t1 = &mMetaTiles[curr.x +
- (curr.y + dy) * mWidth];
- const MetaTile *const t2 = &mMetaTiles[curr.x +
- dx + curWidth];
-
- // on player abilities.
- if (((t1->blockmask | t2->blockmask) & blockWalkMask) != 0)
- continue;
- }
-
- // Calculate G cost for this route, ~sqrt(2) for moving diagonal
- int Gcost = tileGcost + (dx == 0 || dy == 0
- ? basicCost : basicCost2);
-
- /* Demote an arbitrary direction to speed pathfinding by
- adding a defect
- Important: as long as the total defect along any path is
- less than the basicCost, the pathfinder will still find one
- of the shortest paths! */
- if (dx == 0 || dy == 0)
- {
- // Demote horizontal and vertical directions, so that two
- // consecutive directions cannot have the same Fcost.
- ++Gcost;
- }
-
-/*
- // It costs extra to walk through a being (needs to be enough
- // to make it more attractive to walk around).
- if (occupied(x, y))
- {
- Gcost += 3 * basicCost;
- }
-*/
-
- // Skip if Gcost becomes too much
- // Warning: probably not entirely accurate
- if (maxCost > 0 && Gcost > maxCost * basicCost)
- continue;
-
- if (newTile->whichList != mOnOpenList)
- {
- // Found a new tile (not on open nor on closed list)
-
- /* Update Hcost of the new tile. The pathfinder does not
- work reliably if the heuristic cost is higher than the
- real cost. In particular, using Manhattan distance is
- forbidden here. */
- const int dx1 = std::abs(x - destX);
- newTile->Hcost = std::abs(dx1 - dy1) * basicCost +
- std::min(dx1, dy1) * (basicCostF);
-
- // Set the current tile as the parent of the new tile
- newTile->parentX = curr.x;
- newTile->parentY = curr.y;
-
- // Update Gcost and Fcost of new tile
- newTile->Gcost = Gcost;
- newTile->Fcost = Gcost + newTile->Hcost;
-
- if (x != destX || y != destY)
- {
- // Add this tile to the open list
- newTile->whichList = mOnOpenList;
- openList.push(Location(x, y, newTile));
- }
- else
- {
- // Target location was found
- foundPath = true;
- }
- }
- else if (Gcost < newTile->Gcost)
- {
- // Found a shorter route.
- // Update Gcost and Fcost of the new tile
- newTile->Gcost = Gcost;
- newTile->Fcost = Gcost + newTile->Hcost;
-
- // Set the current tile as the parent of the new tile
- newTile->parentX = curr.x;
- newTile->parentY = curr.y;
-
- // Add this tile to the open list (it's already
- // there, but this instance has a lower F score)
- openList.push(Location(x, y, newTile));
- }
- }
- }
- }
-
- // Two new values to indicate whether a tile is on the open or closed list,
- // this way we don't have to clear all the values between each pathfinding.
- if (mOnOpenList > UINT_MAX - 2)
- {
- // We reset the list memebers value.
- mOnClosedList = 1;
- mOnOpenList = 2;
-
- // Clean up the metaTiles
- const int size = mWidth * mHeight;
- for (int i = 0; i < size; ++i)
- mMetaTiles[i].whichList = 0;
- }
- else
- {
- mOnClosedList += 2;
- mOnOpenList += 2;
- }
-
- // If a path has been found, iterate backwards using the parent locations
- // to extract it.
- if (foundPath)
- {
- int pathX = destX;
- int pathY = destY;
-
- while (pathX != startX || pathY != startY)
- {
- // Add the new path node to the start of the path list
- path.push_front(Position(pathX, pathY));
-
- // Find out the next parent
- const MetaTile *const tile = &mMetaTiles[pathX + pathY * mWidth];
- pathX = tile->parentX;
- pathY = tile->parentY;
- }
- }
-
- BLOCK_END("Map::findPath")
- return path;
-}
-
-void Map::addParticleEffect(const std::string &effectFile,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- ParticleEffectData newEffect(effectFile, x, y, w, h);
- mParticleEffects.push_back(newEffect);
-}
-
-void Map::initializeParticleEffects() const restrict2
-{
- BLOCK_START("Map::initializeParticleEffects")
- if (particleEngine == nullptr)
- {
- BLOCK_END("Map::initializeParticleEffects")
- return;
- }
-
- if (config.getBoolValue("particleeffects"))
- {
- for (STD_VECTOR<ParticleEffectData>::const_iterator
- i = mParticleEffects.begin();
- i != mParticleEffects.end();
- ++i)
- {
- Particle *const p = particleEngine->addEffect(
- i->file,
- i->x,
- i->y);
- if ((p != nullptr) &&
- i->w > 0 &&
- i->h > 0)
- {
- p->adjustEmitterSize(i->w, i->h);
- }
- }
- }
- BLOCK_END("Map::initializeParticleEffects")
-}
-
-void Map::addExtraLayer() restrict2
-{
- BLOCK_START("Map::addExtraLayer")
- if (mSpecialLayer == nullptr)
- {
- logger->log1("No special layer");
- BLOCK_END("Map::addExtraLayer")
- return;
- }
- const std::string mapFileName = pathJoin(getUserMapDirectory(),
- "extralayer.txt");
- logger->log("loading extra layer: " + mapFileName);
- struct stat statbuf;
- if (stat(mapFileName.c_str(), &statbuf) == 0 &&
- S_ISREG(statbuf.st_mode))
- {
- std::ifstream mapFile;
- mapFile.open(mapFileName.c_str(), std::ios::in);
- if (!mapFile.is_open())
- {
- mapFile.close();
- BLOCK_END("Map::addExtraLayer")
- return;
- }
- char line[201];
-
- while (mapFile.getline(line, 200))
- {
- std::string buf;
- std::string str = line;
- if (!str.empty())
- {
- std::string x;
- std::string y;
- std::string type1;
- std::string comment;
- std::stringstream ss(str);
- ss >> x;
- ss >> y;
- ss >> type1;
- ss >> comment;
- while (ss >> buf)
- comment.append(" ").append(buf);
-
- const int type = atoi(type1.c_str());
-
- if (comment.empty())
- {
- if (type < MapItemType::ARROW_UP
- || type > MapItemType::ARROW_RIGHT)
- {
- comment = "unknown";
- }
- }
- if (type == MapItemType::PORTAL)
- {
- updatePortalTile(comment, type, atoi(x.c_str()),
- atoi(y.c_str()), false);
- }
- else if (type == MapItemType::HOME)
- {
- updatePortalTile(comment, type, atoi(x.c_str()),
- atoi(y.c_str()));
- }
- else
- {
- addPortalTile(comment, type, atoi(x.c_str()),
- atoi(y.c_str()));
- }
- }
- }
- mapFile.close();
- }
- BLOCK_END("Map::addExtraLayer")
-}
-
-void Map::saveExtraLayer() const restrict2
-{
- if (mSpecialLayer == nullptr)
- {
- logger->log1("No special layer");
- return;
- }
- const std::string mapFileName = pathJoin(getUserMapDirectory(),
- "extralayer.txt");
- logger->log("saving extra layer: " + mapFileName);
-
- if (mkdir_r(getUserMapDirectory().c_str()) != 0)
- {
- logger->log(strprintf("%s doesn't exist and can't be created! "
- "Exiting.", getUserMapDirectory().c_str()));
- return;
- }
-
- std::ofstream mapFile;
- mapFile.open(mapFileName.c_str(), std::ios::binary);
- if (!mapFile.is_open())
- {
- reportAlways("Error opening file for writing: %s",
- mapFileName.c_str());
- return;
- }
-
- const int width = mSpecialLayer->mWidth;
- const int height = mSpecialLayer->mHeight;
-
- for (int x = 0; x < width; x ++)
- {
- for (int y = 0; y < height; y ++)
- {
- const MapItem *restrict const item = mSpecialLayer->getTile(x, y);
- if ((item != nullptr) && item->mType != MapItemType::EMPTY
- && item->mType != MapItemType::HOME)
- {
- mapFile << x << " " << y << " "
- << CAST_S32(item->mType) << " "
- << item->mComment << std::endl;
- }
- }
- }
- mapFile.close();
-}
-
-std::string Map::getUserMapDirectory() const restrict2
-{
- return pathJoin(settings.serverConfigDir,
- getProperty("_realfilename"));
-}
-
-void Map::addRange(const std::string &restrict name,
- const int type,
- const int x, const int y,
- const int dx, const int dy) restrict2
-{
- if (mObjects == nullptr)
- return;
-
- mObjects->addObject(name, type, x / mapTileSize, y / mapTileSize,
- dx / mapTileSize, dy / mapTileSize);
-}
-
-void Map::addPortal(const std::string &restrict name,
- const int type,
- const int x, const int y,
- const int dx, const int dy) restrict2
-{
- addPortalTile(name, type, (x / mapTileSize) + (dx / mapTileSize / 2),
- (y / mapTileSize) + (dy / mapTileSize / 2));
-}
-
-void Map::addPortalTile(const std::string &restrict name,
- const int type,
- const int x, const int y) restrict2
-{
- if (mSpecialLayer != nullptr)
- {
- mSpecialLayer->setTile(x, y, new MapItem(type, name, x, y));
- mSpecialLayer->updateCache();
- }
-
- mMapPortals.push_back(new MapItem(type, name, x, y));
-}
-
-void Map::updatePortalTile(const std::string &restrict name,
- const int type,
- const int x, const int y,
- const bool addNew) restrict2
-{
- MapItem *restrict item = findPortalXY(x, y);
- if (item != nullptr)
- {
- item->mComment = name;
- item->setType(type);
- item->mX = x;
- item->mY = y;
- if (mSpecialLayer != nullptr)
- {
- item = new MapItem(type, name, x, y);
- mSpecialLayer->setTile(x, y, item);
- mSpecialLayer->updateCache();
- }
- }
- else if (addNew)
- {
- addPortalTile(name, type, x, y);
- }
-}
-
-MapItem *Map::findPortalXY(const int x, const int y) const restrict2
-{
- FOR_EACH (STD_VECTOR<MapItem*>::const_iterator, it, mMapPortals)
- {
- if (*it == nullptr)
- continue;
-
- MapItem *restrict const item = *it;
- if (item->mX == x && item->mY == y)
- return item;
- }
- return nullptr;
-}
-
-const TileAnimation *Map::getAnimationForGid(const int gid) const restrict2
-{
- if (mTileAnimations.empty())
- return nullptr;
-
- const TileAnimationMapCIter i = mTileAnimations.find(gid);
- return (i == mTileAnimations.end()) ? nullptr : i->second;
-}
-
-void Map::setPvpMode(const int mode) restrict2
-{
- const int oldMode = mPvp;
-
- if (mode == 0)
- mPvp = 0;
- else
- mPvp |= mode;
-
- if (mPvp != oldMode && (localPlayer != nullptr))
- {
- switch (mPvp)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::PVP_OFF_GVG_OFF);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::PVP_ON);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::GVG_ON);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::PVP_ON_GVG_ON);
- break;
- default:
- NotifyManager::notify(NotifyTypes::PVP_UNKNOWN);
- break;
- }
- }
-}
-
-std::string Map::getObjectData(const unsigned x, const unsigned y,
- const int type) const restrict2
-{
- if (mObjects == nullptr)
- return "";
-
- MapObjectList *restrict const list = mObjects->getAt(x, y);
- if (list == nullptr)
- return "";
-
- STD_VECTOR<MapObject>::const_iterator it = list->objects.begin();
- const STD_VECTOR<MapObject>::const_iterator it_end = list->objects.end();
- while (it != it_end)
- {
- if ((*it).type == type)
- return (*it).data;
- ++ it;
- }
-
- return "";
-}
-
-void Map::indexTilesets() restrict2
-{
- if (mTilesetsIndexed)
- return;
-
- mTilesetsIndexed = true;
-
- const Tileset *restrict s = nullptr;
- size_t sSz = 0;
- FOR_EACH (Tilesets::const_iterator, it, mTilesets)
- {
- const size_t sz = (*it)->size();
- if ((s == nullptr) || CAST_SIZE(s->getFirstGid()) + sSz
- < CAST_SIZE((*it)->getFirstGid()) + sz)
- {
- s = *it;
- sSz = sz;
- }
- }
- if (s == nullptr)
- {
- mIndexedTilesetsSize = 0;
- mIndexedTilesets = nullptr;
- return;
- }
-
- const int size = CAST_S32(s->getFirstGid())
- + CAST_S32(s->size());
- mIndexedTilesetsSize = size;
- mIndexedTilesets = new Tileset*[CAST_SIZE(size)];
- std::fill_n(mIndexedTilesets, size, static_cast<Tileset*>(nullptr));
-
- FOR_EACH (Tilesets::const_iterator, it, mTilesets)
- {
- Tileset *restrict const s2 = *it;
- if (s2 != nullptr)
- {
- const int start = s2->getFirstGid();
- const int end = start + CAST_S32(s2->size());
- for (int f = start; f < end; f ++)
- {
- if (f < size)
- mIndexedTilesets[f] = s2;
- }
- }
- }
-}
-
-void Map::clearIndexedTilesets() restrict2
-{
- if (!mTilesetsIndexed)
- return;
-
- mTilesetsIndexed = false;
- delete [] mIndexedTilesets;
- mIndexedTilesetsSize = 0;
-}
-
-void Map::reduce() restrict2
-{
-#ifdef USE_SDL2
- return;
-#else // USE_SDL2
-
- if ((mFringeLayer == nullptr) ||
- mOpenGL != RENDER_SOFTWARE ||
- !config.getBoolValue("enableMapReduce"))
- {
- return;
- }
-
- int cnt = 0;
- for (int x = 0; x < mWidth; x ++)
- {
- for (int y = 0; y < mHeight; y ++)
- {
- bool correct(true);
- bool dontHaveAlpha(false);
-
- FOR_EACH (LayersCIter, layeri, mLayers)
- {
- const MapLayer *restrict const layer = *layeri;
- if (x >= layer->mWidth || y >= layer->mHeight)
- continue;
-
- // skip layers with flags
- if (layer->mTileCondition != -1 || layer->mMask != 1)
- continue;
-
- Image *restrict const img =
- layer->mTiles[x + y * layer->mWidth].image;
- if (img != nullptr)
- {
- if (img->hasAlphaChannel() && img->isAlphaCalculated())
- {
- if (!img->isAlphaVisible())
- {
- dontHaveAlpha = true;
- img->setAlphaVisible(false);
- }
- }
- else if (img->mBounds.w > mapTileSize
- || img->mBounds.h > mapTileSize)
- {
- correct = false;
- img->setAlphaVisible(true);
- break;
- }
- else if (!img->isHasAlphaChannel())
- {
- dontHaveAlpha = true;
- img->setAlphaVisible(false);
- }
- else if (img->hasAlphaChannel())
- {
- const uint8_t *restrict const arr =
- img->SDLgetAlphaChannel();
- if (arr == nullptr)
- continue;
-
- bool bad(false);
- bool stop(false);
- int width;
- const SubImage *restrict const subImg
- = dynamic_cast<SubImage*>(img);
- if (subImg != nullptr)
- width = subImg->mInternalBounds.w;
- else
- width = img->mBounds.w;
-
- for (int f = img->mBounds.x;
- f < img->mBounds.x + img->mBounds.w; f ++)
- {
- for (int d = img->mBounds.y;
- d < img->mBounds.y + img->mBounds.h; d ++)
- {
- const uint8_t chan = arr[f + d * width];
- if (chan != 255)
- {
- bad = true;
- stop = true;
- break;
- }
- }
- if (stop)
- break;
- }
- if (!bad)
- {
- dontHaveAlpha = true;
- img->setAlphaVisible(false);
- }
- else
- {
- img->setAlphaVisible(true);
- }
- }
- img->setAlphaCalculated(true);
- }
- }
- if (!correct || !dontHaveAlpha)
- continue;
-
- Layers::reverse_iterator ri = mLayers.rbegin();
- while (ri != mLayers.rend())
- {
- const MapLayer *restrict const layer = *ri;
- if (x >= layer->mWidth || y >= layer->mHeight)
- {
- ++ ri;
- continue;
- }
-
- // skip layers with flags
- if (layer->mTileCondition != -1 || layer->mMask != 1)
- {
- ++ ri;
- continue;
- }
-
- const Image *restrict img =
- layer->mTiles[x + y * layer->mWidth].image;
- if ((img != nullptr) && !img->isAlphaVisible())
- { // removing all down tiles
- ++ ri;
- while (ri != mLayers.rend())
- {
- MapLayer *restrict const layer2 = *ri;
- // skip layers with flags
- if (layer2->mTileCondition != -1 || layer2->mMask != 1)
- {
- ++ ri;
- continue;
- }
- const size_t pos = CAST_SIZE(
- x + y * layer2->mWidth);
- img = layer2->mTiles[pos].image;
- if (img != nullptr)
- {
- layer2->mTiles[pos].image = nullptr;
- cnt ++;
- }
- ++ ri;
- }
- break;
- }
- ++ ri;
- }
- }
- }
- logger->log("tiles reduced: %d", cnt);
-#endif // USE_SDL2
-}
-
-void Map::addHeights(const MapHeights *restrict const heights) restrict2
-{
- delete mHeights;
- mHeights = heights;
-}
-
-uint8_t Map::getHeightOffset(const int x, const int y) const restrict2
-{
- if (mHeights == nullptr)
- return 0;
- return mHeights->getHeight(x, y);
-}
-
-void Map::updateDrawLayersList() restrict2
-{
- mDrawUnderLayers.clear();
- mDrawOverLayers.clear();
-
- if (mDrawOnlyFringe)
- return;
-
- LayersCIter layers = mLayers.begin();
- const LayersCIter layers_end = mLayers.end();
- for (; layers != layers_end; ++ layers)
- {
- MapLayer *const layer = *layers;
- if ((layer->mMask & mMask) == 0)
- continue;
-
- if (layer->isFringeLayer())
- {
- ++ layers;
- break;
- }
-
- mDrawUnderLayers.push_back(layer);
- }
-
- if (mDrawLayersFlags == MapType::SPECIAL2)
- return;
-
- for (; layers != layers_end; ++ layers)
- {
- MapLayer *const layer = *layers;
- if ((layer->mMask & mMask) == 0)
- continue;
-
- mDrawOverLayers.push_back(layer);
- }
-}
-
-void Map::setMask(const int mask) restrict2
-{
- if (mask != mMask)
- {
- mRedrawMap = true;
- mMask = mask;
- updateDrawLayersList();
- }
-}
-
-void Map::setMusicFile(const std::string &restrict file) restrict2
-{
- setProperty("music", file);
-}
-
-void Map::addAnimation(const int gid,
- TileAnimation *restrict const animation) restrict2
-{
- std::map<int, TileAnimation*>::iterator it = mTileAnimations.find(gid);
- if (it != mTileAnimations.end())
- {
- logger->log("duplicate map animation with gid = %d", gid);
- delete (*it).second;
- }
- mTileAnimations[gid] = animation;
-}
-
-void Map::setDrawLayersFlags(const MapTypeT &restrict n) restrict2
-{
- mDrawLayersFlags = n;
- if (mDrawLayersFlags == MapType::SPECIAL3 ||
- mDrawLayersFlags == MapType::SPECIAL4 ||
- mDrawLayersFlags == MapType::BLACKWHITE)
- {
- mDrawOnlyFringe = true;
- }
- else
- {
- mDrawOnlyFringe = false;
- }
- updateDrawLayersList();
- FOR_EACH (Layers::iterator, it, mLayers)
- {
- MapLayer *restrict const layer = *it;
- layer->setDrawLayerFlags(mDrawLayersFlags);
- }
-}
-
-void Map::setActorsFix(const int x, const int y) restrict2
-{
- mActorFixX = x;
- mActorFixY = y;
- if (mFringeLayer != nullptr)
- mFringeLayer->setActorsFix(y);
-}
-
-void Map::updateConditionLayers() restrict2
-{
- mRedrawMap = true;
-
- FOR_EACH (LayersCIter, it, mLayers)
- {
- MapLayer *restrict const layer = *it;
- if ((layer == nullptr) || layer->mTileCondition == -1)
- continue;
- layer->updateConditionTiles(mMetaTiles,
- mWidth, mHeight);
- }
-}
-
-void Map::preCacheLayers() restrict2
-{
- FOR_EACH (LayersCIter, it, mLayers)
- {
- MapLayer *restrict const layer = *it;
- if (layer != nullptr)
- layer->updateCache(mWidth, mHeight);
- }
-}
-
-int Map::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(Map) +
- mName.capacity() +
- sizeof(MetaTile) * mWidth * mHeight +
- sizeof(MapLayer*) * (mLayers.capacity() +
- mDrawUnderLayers.capacity() +
- mDrawOverLayers.capacity()) +
- sizeof(Tileset*) * mTilesets.capacity() +
- sizeof(Actor*) * mActors.size() +
- sizeof(AmbientLayer*) * (mBackgrounds.capacity()
- + mForegrounds.capacity()) +
- sizeof(ParticleEffectData) * mParticleEffects.capacity() +
- sizeof(MapItem) * mMapPortals.capacity() +
- (sizeof(TileAnimation) + sizeof(int)) * mTileAnimations.size() +
- sizeof(Tileset*) * mIndexedTilesetsSize);
-}
-
-int Map::calcMemoryChilds(const int level) const
-{
- int sz = 0;
-
- if (mWalkLayer != nullptr)
- sz += mWalkLayer->calcMemory(level + 1);
- FOR_EACH (LayersCIter, it, mLayers)
- {
- sz += (*it)->calcMemory(level + 1);
- }
- FOR_EACH (Tilesets::const_iterator, it, mTilesets)
- {
- sz += (*it)->calcMemory(level + 1);
- }
- FOR_EACH (AmbientLayerVectorCIter, it, mBackgrounds)
- {
- sz += (*it)->calcMemory(level + 1);
- }
- FOR_EACH (AmbientLayerVectorCIter, it, mForegrounds)
- {
- sz += (*it)->calcMemory(level + 1);
- }
- if (mSpecialLayer != nullptr)
- mSpecialLayer->calcMemory(level + 1);
- if (mTempLayer != nullptr)
- mTempLayer->calcMemory(level + 1);
- if (mObjects != nullptr)
- mObjects->calcMemory(level + 1);
- if (mHeights != nullptr)
- mHeights->calcMemory(level + 1);
- return sz;
-}
diff --git a/src/resources/map/map.h b/src/resources/map/map.h
deleted file mode 100644
index dc05cb2ea..000000000
--- a/src/resources/map/map.h
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_MAP_H
-#define RESOURCES_MAP_MAP_H
-
-#include "position.h"
-
-#include "being/actor.h"
-
-#include "enums/render/rendertype.h"
-
-#include "enums/resources/map/blocktype.h"
-#include "enums/resources/map/maplayerposition.h"
-#include "enums/resources/map/maptype.h"
-
-#include "listeners/configlistener.h"
-
-#include "utils/vector.h"
-
-#include "resources/memorycounter.h"
-
-#include "resources/map/properties.h"
-
-class AmbientLayer;
-class MapHeights;
-class MapItem;
-class MapLayer;
-class ObjectsLayer;
-class Resource;
-class SpecialLayer;
-class Tileset;
-class TileAnimation;
-class WalkLayer;
-
-struct MetaTile;
-
-typedef STD_VECTOR<Tileset*> Tilesets;
-typedef STD_VECTOR<MapLayer*> Layers;
-typedef Layers::const_iterator LayersCIter;
-
-typedef STD_VECTOR<AmbientLayer*> AmbientLayerVector;
-typedef AmbientLayerVector::const_iterator AmbientLayerVectorCIter;
-typedef AmbientLayerVector::iterator AmbientLayerVectorIter;
-
-/**
- * A tile map.
- */
-class Map final : public Properties,
- public ConfigListener,
- public MemoryCounter
-{
- public:
- /**
- * Constructor, taking map and tile size as parameters.
- */
- Map(const std::string &name,
- const int width,
- const int height,
- const int tileWidth,
- const int tileHeight);
-
- A_DELETE_COPY(Map)
-
- /**
- * Destructor.
- */
- ~Map();
-
- /**
- * Initialize ambient layers. Has to be called after all the properties
- * are set.
- */
- void initializeAmbientLayers() restrict2;
-
- /**
- * Updates animations. Called as needed.
- */
- void update(const int ticks = 1) restrict2;
-
- /**
- * Draws the map to the given graphics output. This method draws all
- * layers, actors and overlay effects.
- */
- void draw(Graphics *restrict const graphics,
- int scrollX,
- int scrollY) restrict2 A_NONNULL(2);
-
- /**
- * Visualizes collision layer for debugging
- */
- void drawCollision(Graphics *restrict const graphics,
- const int scrollX,
- const int scrollY,
- const MapTypeT drawFlags) const
- restrict2 A_NONNULL(2);
-
- /**
- * Adds a layer to this map. The map takes ownership of the layer.
- */
- void addLayer(MapLayer *const layer) restrict2 A_NONNULL(2);
-
- /**
- * Adds a tileset to this map. The map takes ownership of the tileset.
- */
- void addTileset(Tileset *const tileset) restrict2 A_NONNULL(2);
-
- /**
- * Finds the tile set that a tile with the given global id is part of.
- */
- const Tileset *getTilesetWithGid(const int gid) const
- restrict2 A_WARN_UNUSED;
-
- /**
- * Get tile reference.
- */
- const MetaTile *getMetaTile(const int x,
- const int y) const
- restrict2 A_WARN_UNUSED;
-
- void addBlockMask(const int x, const int y,
- const BlockTypeT type) restrict2;
-
- void setBlockMask(const int x, const int y,
- const BlockTypeT type) restrict2;
-
- /**
- * Gets walkability for a tile with a blocking bitmask. When called
- * without walkmask, only blocks against colliding tiles.
- */
- bool getWalk(const int x, const int y,
- const unsigned char blockWalkMask) const
- restrict2 A_WARN_UNUSED;
-
- void setWalk(const int x, const int y) restrict2;
-
- unsigned char getBlockMask(const int x,
- const int y) const restrict2;
-
- /**
- * Returns the width of this map in tiles.
- */
- int getWidth() const restrict2 noexcept2 A_WARN_UNUSED
- { return mWidth; }
-
- /**
- * Returns the height of this map in tiles.
- */
- int getHeight() const restrict2 noexcept2 A_WARN_UNUSED
- { return mHeight; }
-
- /**
- * Returns the tile width of this map.
- */
- int getTileWidth() const restrict2 noexcept2 A_WARN_UNUSED
- { return mTileWidth; }
-
- /**
- * Returns the tile height used by this map.
- */
- int getTileHeight() const restrict2 noexcept2 A_WARN_UNUSED
- { return mTileHeight; }
-
- const std::string getMusicFile() const restrict2 A_WARN_UNUSED;
-
- void setMusicFile(const std::string &restrict file) restrict2;
-
- const std::string getName() const restrict2 A_WARN_UNUSED;
-
- /**
- * Gives the map id based on filepath (ex: 009-1)
- */
- const std::string getFilename() const restrict2 A_WARN_UNUSED;
-
- const std::string getGatName() const restrict2 A_WARN_UNUSED;
-
- /**
- * Find a path from one location to the next.
- */
- Path findPath(const int startX, const int startY,
- const int destX, const int destY,
- const unsigned char blockWalkmask,
- const int maxCost = 20) restrict2 A_WARN_UNUSED;
-
- /**
- * Adds a particle effect
- */
- void addParticleEffect(const std::string &restrict effectFile,
- const int x,
- const int y,
- const int w = 0,
- const int h = 0) restrict2;
-
- /**
- * Initializes all added particle effects
- */
- void initializeParticleEffects() const restrict2;
-
- /**
- * Adds a tile animation to the map
- */
- void addAnimation(const int gid,
- TileAnimation *restrict const animation) restrict2
- A_NONNULL(3);
-
- void setDrawLayersFlags(const MapTypeT &restrict n) restrict2;
-
- MapTypeT getDrawLayersFlags() const restrict2 A_WARN_UNUSED
- { return mDrawLayersFlags; }
-
- void addExtraLayer() restrict2;
-
- void saveExtraLayer() const restrict2;
-
- SpecialLayer *getTempLayer() const restrict2 noexcept2 A_WARN_UNUSED
- { return mTempLayer; }
-
- SpecialLayer *getSpecialLayer() const restrict2 noexcept2 A_WARN_UNUSED
- { return mSpecialLayer; }
-
- void setHasWarps(const bool n) restrict2 noexcept2
- { mHasWarps = n; }
-
- bool getHasWarps() const restrict2 noexcept2 A_WARN_UNUSED
- { return mHasWarps; }
-
- std::string getUserMapDirectory() const restrict2 A_WARN_UNUSED;
-
- void addPortal(const std::string &restrict name,
- const int type,
- const int x, const int y,
- const int dx, const int dy) restrict2;
-
- void addRange(const std::string &restrict name,
- const int type,
- const int x, const int y,
- const int dx, const int dy) restrict2;
-
- void addPortalTile(const std::string &restrict name,
- const int type,
- const int x, const int y) restrict2;
-
- void updatePortalTile(const std::string &restrict name,
- const int type,
- const int x, const int y,
- const bool addNew = true) restrict2;
-
- const STD_VECTOR<MapItem*> &getPortals() const restrict2 noexcept2
- A_WARN_UNUSED
- { return mMapPortals; }
-
- /**
- * Gets the tile animation for a specific gid
- */
- const TileAnimation *getAnimationForGid(const int gid)
- const restrict2 A_WARN_UNUSED;
-
- void optionChanged(const std::string &restrict value)
- restrict2 override final;
-
- MapItem *findPortalXY(const int x,
- const int y) const restrict2 A_WARN_UNUSED;
-
- int getActorsCount() const restrict2 A_WARN_UNUSED
- { return CAST_S32(mActors.size()); }
-
- void setPvpMode(const int mode) restrict2;
-
- int getPvpMode() const restrict2 noexcept2 A_WARN_UNUSED
- { return mPvp; }
-
- const ObjectsLayer* getObjectsLayer() const restrict2 noexcept2
- A_WARN_UNUSED
- { return mObjects; }
-
- std::string getObjectData(const unsigned x,
- const unsigned y,
- const int type) const
- restrict2 A_WARN_UNUSED;
-
- void indexTilesets() restrict2;
-
- void clearIndexedTilesets() restrict2;
-
- void setActorsFix(const int x, const int y) restrict2;
-
- int getVersion() const restrict2 noexcept2 A_WARN_UNUSED
- { return mVersion; }
-
- void setVersion(const int n) restrict2 noexcept2
- { mVersion = n; }
-
- void reduce() restrict2;
-
- void redrawMap() restrict2 noexcept2
- { mRedrawMap = true; }
-
- bool empty() const restrict2 A_WARN_UNUSED
- { return mLayers.empty(); }
-
- void setCustom(const bool b) restrict2 noexcept2
- { mCustom = b; }
-
- bool isCustom() const restrict2 noexcept2 A_WARN_UNUSED
- { return mCustom; }
-
- const std::map<int, TileAnimation*> &getTileAnimations() const
- restrict2 noexcept2 A_WARN_UNUSED
- { return mTileAnimations; }
-
- void setAtlas(Resource *restrict const atlas) restrict2 noexcept2
- { mAtlas = atlas; }
-
- const MetaTile *getMetaTiles() const restrict2 noexcept2
- { return mMetaTiles; }
-
- const WalkLayer *getWalkLayer() const restrict2 noexcept2
- { return mWalkLayer; }
-
- void setWalkLayer(WalkLayer *restrict const layer) restrict2 noexcept2
- { mWalkLayer = layer; }
-
- void addHeights(const MapHeights *restrict const heights) restrict2
- A_NONNULL(2);
-
- uint8_t getHeightOffset(const int x, const int y) const restrict2;
-
- void setMask(const int mask) restrict2;
-
- void updateDrawLayersList() restrict2;
-
- bool isHeightsPresent() const restrict2 noexcept2
- { return mHeights != nullptr; }
-
- void updateConditionLayers() restrict2;
-
- void preCacheLayers() restrict2;
-
- int calcMemoryLocal() const override final;
-
- int calcMemoryChilds(const int level) const override final;
-
- std::string getCounterName() const override final
- { return mName; }
-
- bool haveAtlas() const
- { return mAtlas != nullptr; }
-
- protected:
- friend class Actor;
- friend class Minimap;
-
- /**
- * Adds an actor to the map.
- */
- Actors::iterator addActor(Actor *const actor) restrict2 A_NONNULL(2);
-
- /**
- * Removes an actor from the map.
- */
- void removeActor(const Actors::iterator &restrict iterator) restrict2;
-
- private:
- /**
- * Updates scrolling of ambient layers. Has to be called each game tick.
- */
- void updateAmbientLayers(const float scrollX,
- const float scrollY) restrict2;
-
- /**
- * Draws the foreground or background layers to the given graphics output.
- */
- void drawAmbientLayers(Graphics *restrict const graphics,
- const MapLayerPositionT type,
- const int detail) const restrict2 A_NONNULL(2);
-
- /**
- * Tells whether the given coordinates fall within the map boundaries.
- */
- bool contains(const int x,
- const int y) const restrict2 A_WARN_UNUSED;
-
- const int mWidth;
- const int mHeight;
- const int mTileWidth;
- const int mTileHeight;
- int mMaxTileHeight;
- MetaTile *const mMetaTiles;
- WalkLayer *mWalkLayer;
- Layers mLayers;
- Layers mDrawUnderLayers;
- Layers mDrawOverLayers;
- Tilesets mTilesets;
- Actors mActors;
- bool mHasWarps;
-
- // draw flags
- MapTypeT mDrawLayersFlags;
-
- // Pathfinding members
- unsigned int mOnClosedList;
- unsigned int mOnOpenList;
-
- // Overlay data
- AmbientLayerVector mBackgrounds;
- AmbientLayerVector mForegrounds;
- float mLastAScrollX;
- float mLastAScrollY;
-
- // Particle effect data
- struct ParticleEffectData final
- {
- ParticleEffectData(const std::string &restrict file0,
- const int x0,
- const int y0,
- const int w0,
- const int h0) noexcept2 :
- file(file0),
- x(x0),
- y(y0),
- w(w0),
- h(h0)
- {
- }
-
- A_DEFAULT_COPY(ParticleEffectData)
-
- const2 std::string file;
- const2 int x;
- const2 int y;
- const2 int w;
- const2 int h;
- };
- STD_VECTOR<ParticleEffectData> mParticleEffects;
-
- STD_VECTOR<MapItem*> mMapPortals;
-
- std::map<int, TileAnimation*> mTileAnimations;
-
- std::string mName;
- int mOverlayDetail;
- float mOpacity;
- const RenderType mOpenGL;
- int mPvp;
- bool mTilesetsIndexed;
- Tileset** mIndexedTilesets;
- int mIndexedTilesetsSize;
- int mActorFixX;
- int mActorFixY;
- int mVersion;
-
- SpecialLayer *mSpecialLayer;
- SpecialLayer *mTempLayer;
- ObjectsLayer *mObjects;
- MapLayer *mFringeLayer;
-
- int mLastX;
- int mLastY;
- int mLastScrollX;
- int mLastScrollY;
-
- int mDrawX;
- int mDrawY;
- int mDrawScrollX;
- int mDrawScrollY;
- int mMask;
- Resource *mAtlas;
- const MapHeights *mHeights;
- bool mRedrawMap;
- bool mBeingOpacity;
- bool mCachedDraw;
- bool mCustom;
- bool mDrawOnlyFringe;
-};
-
-#endif // RESOURCES_MAP_MAP_H
diff --git a/src/resources/map/mapheights.cpp b/src/resources/map/mapheights.cpp
deleted file mode 100644
index a6309bbce..000000000
--- a/src/resources/map/mapheights.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/map/mapheights.h"
-
-#include "debug.h"
-
-MapHeights::MapHeights(const int width,
- const int height) :
- MemoryCounter(),
- mWidth(width),
- mHeight(height),
- mTiles(new uint8_t[mWidth * mHeight])
-{
- memset(mTiles, 0, mWidth * mHeight);
-}
-
-MapHeights::~MapHeights()
-{
- delete [] mTiles;
-}
-
-void MapHeights::setHeight(const int x, const int y, const uint8_t height)
-{
- mTiles[x + y * mWidth] = height;
-}
-
-int MapHeights::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(MapHeights)) +
- mWidth * mHeight;
-}
diff --git a/src/resources/map/mapheights.h b/src/resources/map/mapheights.h
deleted file mode 100644
index ef8c4151b..000000000
--- a/src/resources/map/mapheights.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_MAPHEIGHTS_H
-#define RESOURCES_MAP_MAPHEIGHTS_H
-
-#include "resources/memorycounter.h"
-
-#include "utils/cast.h"
-
-#include "localconsts.h"
-
-class MapHeights final : public MemoryCounter
-{
- public:
- friend class Map;
-
- MapHeights(const int width, const int height);
-
- A_DELETE_COPY(MapHeights)
-
- ~MapHeights();
-
- void setHeight(const int x, const int y, const uint8_t height);
-
- uint8_t getHeight(const int x, const int y) const
- {
- return x < mWidth &&
- y < mHeight ? mTiles[x + y * mWidth] : CAST_U8(0U);
- }
-
- int calcMemoryLocal() const override final;
-
- std::string getCounterName() const override final
- { return "heights layer"; }
-
- private:
- int mWidth;
- int mHeight;
- uint8_t *mTiles;
-};
-
-#endif // RESOURCES_MAP_MAPHEIGHTS_H
diff --git a/src/resources/map/mapitem.cpp b/src/resources/map/mapitem.cpp
deleted file mode 100644
index ff4b6b13e..000000000
--- a/src/resources/map/mapitem.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/map/mapitem.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "gui/gui.h"
-#include "gui/userpalette.h"
-
-#include "gui/fonts/font.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-MapItem::MapItem() :
- mImage(nullptr),
- mComment(),
- mName(),
- mType(MapItemType::EMPTY),
- mX(-1),
- mY(-1)
-{
- setType(MapItemType::EMPTY);
-}
-
-MapItem::MapItem(const int type) :
- mImage(nullptr),
- mComment(),
- mName(),
- mType(type),
- mX(-1),
- mY(-1)
-{
- setType(type);
-}
-
-MapItem::MapItem(const int type,
- const std::string &comment) :
- mImage(nullptr),
- mComment(comment),
- mName(),
- mType(type),
- mX(-1),
- mY(-1)
-{
- setType(type);
-}
-
-MapItem::MapItem(const int type,
- const std::string &comment,
- const int x,
- const int y) :
- mImage(nullptr),
- mComment(comment),
- mName(),
- mType(type),
- mX(x),
- mY(y)
-{
- setType(type);
-}
-
-MapItem::~MapItem()
-{
- if (mImage != nullptr)
- {
- mImage->decRef();
- mImage = nullptr;
- }
-}
-
-void MapItem::setType(const int type)
-{
- std::string name;
- mType = type;
- if (mImage != nullptr)
- mImage->decRef();
-
- switch (type)
- {
- case MapItemType::ARROW_UP:
- name = "graphics/sprites/arrow_up.png";
- break;
- case MapItemType::ARROW_DOWN:
- name = "graphics/sprites/arrow_down.png";
- break;
- case MapItemType::ARROW_LEFT:
- name = "graphics/sprites/arrow_left.png";
- break;
- case MapItemType::ARROW_RIGHT:
- name = "graphics/sprites/arrow_right.png";
- break;
- default:
- break;
- }
-
- if (!name.empty())
- mImage = Loader::getImage(name);
- else
- mImage = nullptr;
-}
-
-void MapItem::setPos(const int x, const int y)
-{
- mX = x;
- mY = y;
-}
-
-void MapItem::draw(Graphics *const graphics, const int x, const int y,
- const int dx, const int dy) const
-{
- BLOCK_START("MapItem::draw")
- if (mImage != nullptr)
- graphics->drawImage(mImage, x, y);
-
- switch (mType)
- {
- case MapItemType::ROAD:
- case MapItemType::CROSS:
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::ROAD_POINT));
- graphics->fillRectangle(Rect(x + dx / 3, y + dy / 3,
- dx / 3, dy / 3));
- break;
- case MapItemType::HOME:
- {
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::HOME_PLACE));
- graphics->fillRectangle(Rect(x, y, dx, dy));
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::HOME_PLACE_BORDER));
- graphics->drawRectangle(Rect(x, y, dx, dy));
- break;
- }
- default:
- break;
- }
- if (!mName.empty()
- && mType != MapItemType::PORTAL
- && mType != MapItemType::EMPTY)
- {
- Font *const font = gui->getFont();
- const Color &color = userPalette->getColor(UserColorId::BEING);
- font->drawString(graphics,
- color,
- color,
- mName,
- x, y);
- }
- BLOCK_END("MapItem::draw")
-}
diff --git a/src/resources/map/mapitem.h b/src/resources/map/mapitem.h
deleted file mode 100644
index cefbaea57..000000000
--- a/src/resources/map/mapitem.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_MAPITEM_H
-#define RESOURCES_MAP_MAPITEM_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class Graphics;
-class Image;
-
-class MapItem final
-{
- public:
- friend class Map;
- friend class MapLayer;
- friend class SpecialLayer;
-
- MapItem();
-
- explicit MapItem(const int type);
-
- MapItem(const int type,
- const std::string &comment);
-
- MapItem(const int type,
- const std::string &comment,
- const int x,
- const int y);
-
- A_DELETE_COPY(MapItem)
-
- ~MapItem();
-
- int getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- void setType(const int type);
-
- void setPos(const int x, const int y);
-
- int getX() const noexcept2 A_WARN_UNUSED
- { return mX; }
-
- int getY() const noexcept2 A_WARN_UNUSED
- { return mY; }
-
- const std::string &getComment() const noexcept2 A_WARN_UNUSED
- { return mComment; }
-
- void setComment(const std::string &comment) noexcept2
- { mComment = comment; }
-
- const std::string &getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- void setName(const std::string &name) noexcept2
- { mName = name; }
-
- void draw(Graphics *const graphics,
- const int x, const int y,
- const int dx, const int dy) const A_NONNULL(2);
-
- private:
- Image *mImage;
- std::string mComment;
- std::string mName;
- int mType;
- int mX;
- int mY;
-};
-
-#endif // RESOURCES_MAP_MAPITEM_H
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
deleted file mode 100644
index b55637143..000000000
--- a/src/resources/map/maplayer.cpp
+++ /dev/null
@@ -1,853 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/map/maplayer.h"
-
-#include "configuration.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/map/blockmask.h"
-#include "enums/resources/map/mapitemtype.h"
-
-#include "gui/userpalette.h"
-
-#ifdef USE_OPENGL
-#include "utils/foreach.h"
-#endif // USE_OPENGL
-
-#include "render/graphics.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/mapitem.h"
-#include "resources/map/maprowvertexes.h"
-#include "resources/map/metatile.h"
-#include "resources/map/speciallayer.h"
-
-#include "debug.h"
-
-MapLayer::MapLayer(const std::string &name,
- const int x,
- const int y,
- const int width,
- const int height,
- const bool fringeLayer,
- const int mask,
- const int tileCondition) :
- mX(x),
- mY(y),
- mPixelX(mX * mapTileSize),
- mPixelY(mY * mapTileSize + mapTileSize),
- mWidth(width),
- mHeight(height),
- mTiles(new TileInfo[mWidth * mHeight]),
- mDrawLayerFlags(MapType::NORMAL),
- mSpecialLayer(nullptr),
- mTempLayer(nullptr),
- mName(name),
- mTempRows(),
- mMask(mask),
- mTileCondition(tileCondition),
- mActorsFix(0),
- mIsFringeLayer(fringeLayer),
- mHighlightAttackRange(config.getBoolValue("highlightAttackRange")),
- mSpecialFlag(true)
-{
-// std::fill_n(mTiles, mWidth * mHeight, static_cast<Image*>(nullptr));
-
- config.addListener("highlightAttackRange", this);
-}
-
-MapLayer::~MapLayer()
-{
- config.removeListener("highlightAttackRange", this);
- CHECKLISTENERS
- delete []mTiles;
- delete_all(mTempRows);
- mTempRows.clear();
-}
-
-void MapLayer::optionChanged(const std::string &value) restrict
-{
- if (value == "highlightAttackRange")
- {
- mHighlightAttackRange =
- config.getBoolValue("highlightAttackRange");
- }
-}
-
-void MapLayer::setTile(const int x,
- const int y,
- Image *const img) restrict
-{
- mTiles[x + y * mWidth].image = img;
-}
-
-void MapLayer::draw(Graphics *const graphics,
- int startX,
- int startY,
- int endX,
- int endY,
- const int scrollX,
- const int scrollY) const restrict
-{
- BLOCK_START("MapLayer::draw")
- startX -= mX;
- startY -= mY;
- endX -= mX;
- endY -= mY;
-
- if (startX < 0)
- startX = 0;
- if (startY < 0)
- startY = 0;
- if (endX > mWidth)
- endX = mWidth;
- if (endY > mHeight)
- endY = mHeight;
-
- const int dx = mPixelX - scrollX;
- const int dy = mPixelY - scrollY;
- for (int y = startY; y < endY; y++)
- {
- const int y32 = y * mapTileSize;
- const int yWidth = y * mWidth;
-
- const int py0 = y32 + dy;
-
- int x0 = startX;
- TileInfo *tilePtr = &mTiles[CAST_SIZE(x0 + yWidth)];
- if (tilePtr->isEnabled == false)
- {
- if (x0 + tilePtr->nextTile + 1 >= endX)
- {
- continue;
- }
- x0 += tilePtr->nextTile + 1;
- tilePtr = &mTiles[CAST_SIZE(x0 + yWidth)];
- if (mTiles[x0 + yWidth].isEnabled == false)
- {
- continue;
- }
- }
- for (int x = x0; x < endX; x++, tilePtr++)
- {
- const int x32 = x * mapTileSize;
-
- const Image *const img = tilePtr->image;
- const int px = x32 + dx;
- const int py = py0 - img->mBounds.h;
- if (mSpecialFlag ||
- img->mBounds.h <= mapTileSize)
- {
- if (tilePtr->count == 0)
- {
- graphics->drawImage(img, px, py);
- }
- else
- {
- graphics->drawPattern(img,
- px,
- py,
- tilePtr->width,
- img->mBounds.h);
- }
- }
-
- const int nextTile = tilePtr->nextTile;
- x += nextTile;
- tilePtr += nextTile;
- }
- }
- BLOCK_END("MapLayer::draw")
-}
-
-void MapLayer::drawSDL(Graphics *const graphics) const restrict2
-{
- BLOCK_START("MapLayer::drawSDL")
- MapRows::const_iterator rit = mTempRows.begin();
- const MapRows::const_iterator rit_end = mTempRows.end();
- while (rit != rit_end)
- {
- MapRowImages *const images = &(*rit)->images;
- MapRowImages::const_iterator iit = images->begin();
- const MapRowImages::const_iterator iit_end = images->end();
- while (iit != iit_end)
- {
- graphics->drawTileVertexes(*iit);
- ++ iit;
- }
- ++ rit;
- }
- BLOCK_END("MapLayer::drawSDL")
-}
-
-#ifdef USE_OPENGL
-void MapLayer::updateSDL(const Graphics *const graphics,
- int startX,
- int startY,
- int endX,
- int endY,
- const int scrollX,
- const int scrollY) restrict2
-{
- BLOCK_START("MapLayer::updateSDL")
- delete_all(mTempRows);
- mTempRows.clear();
-
- startX -= mX;
- startY -= mY;
- endX -= mX;
- endY -= mY;
-
- if (startX < 0)
- startX = 0;
- if (startY < 0)
- startY = 0;
- if (endX > mWidth)
- endX = mWidth;
- if (endY > mHeight)
- endY = mHeight;
-
- const int dx = mPixelX - scrollX;
- const int dy = mPixelY - scrollY;
-
- for (int y = startY; y < endY; y++)
- {
- MapRowVertexes *const row = new MapRowVertexes;
- mTempRows.push_back(row);
-
- const Image *lastImage = nullptr;
- ImageVertexes *imgVert = nullptr;
-
- const int yWidth = y * mWidth;
- const int py0 = y * mapTileSize + dy;
- TileInfo *tilePtr = &mTiles[CAST_SIZE(startX + yWidth)];
-
- for (int x = startX; x < endX; x++, tilePtr++)
- {
- if (!tilePtr->isEnabled)
- continue;
- Image *const img = (*tilePtr).image;
- const int px = x * mapTileSize + dx;
- const int py = py0 - img->mBounds.h;
- if (mSpecialFlag ||
- img->mBounds.h <= mapTileSize)
- {
- if (lastImage != img)
- {
- imgVert = new ImageVertexes;
- imgVert->image = img;
- row->images.push_back(imgVert);
- lastImage = img;
- }
- graphics->calcTileSDL(imgVert, px, py);
- }
- }
- }
- BLOCK_END("MapLayer::updateSDL")
-}
-
-void MapLayer::updateOGL(Graphics *const graphics,
- int startX,
- int startY,
- int endX,
- int endY,
- const int scrollX,
- const int scrollY) restrict2
-{
- BLOCK_START("MapLayer::updateOGL")
- delete_all(mTempRows);
- mTempRows.clear();
-
- startX -= mX;
- startY -= mY;
- endX -= mX;
- endY -= mY;
-
- if (startX < 0)
- startX = 0;
- if (startY < 0)
- startY = 0;
- if (endX > mWidth)
- endX = mWidth;
- if (endY > mHeight)
- endY = mHeight;
-
- const int dx = mPixelX - scrollX;
- const int dy = mPixelY - scrollY;
-
- MapRowVertexes *const row = new MapRowVertexes;
- mTempRows.push_back(row);
- Image *lastImage = nullptr;
- ImageVertexes *imgVert = nullptr;
- typedef std::map<int, ImageVertexes*> ImageVertexesMap;
- ImageVertexesMap imgSet;
-
- for (int y = startY; y < endY; y++)
- {
- const int yWidth = y * mWidth;
- const int py0 = y * mapTileSize + dy;
- TileInfo *tilePtr = &mTiles[CAST_SIZE(startX + yWidth)];
- for (int x = startX; x < endX; x++, tilePtr++)
- {
- if (!tilePtr->isEnabled)
- continue;
- Image *const img = (*tilePtr).image;
- const int px = x * mapTileSize + dx;
- const int py = py0 - img->mBounds.h;
- const GLuint imgGlImage = img->mGLImage;
- if (mSpecialFlag ||
- img->mBounds.h <= mapTileSize)
- {
- if ((lastImage == nullptr) ||
- lastImage->mGLImage != imgGlImage)
- {
- if (img->mBounds.w > mapTileSize)
- imgSet.clear();
-
- if (imgSet.find(imgGlImage) != imgSet.end())
- {
- imgVert = imgSet[imgGlImage];
- }
- else
- {
- if (lastImage != nullptr)
- imgSet[lastImage->mGLImage] = imgVert;
- imgVert = new ImageVertexes;
- imgVert->ogl.init();
- imgVert->image = img;
- row->images.push_back(imgVert);
- }
- }
- lastImage = img;
- graphics->calcTileVertexes(imgVert, lastImage, px, py);
- }
- }
- }
- FOR_EACH (MapRowImages::iterator, it, row->images)
- {
- graphics->finalize(*it);
- }
- BLOCK_END("MapLayer::updateOGL")
-}
-
-void MapLayer::drawOGL(Graphics *const graphics) const restrict2
-{
- BLOCK_START("MapLayer::drawOGL")
- MapRows::const_iterator rit = mTempRows.begin();
- const MapRows::const_iterator rit_end = mTempRows.end();
- while (rit != rit_end)
- {
- const MapRowImages *const images = &(*rit)->images;
- MapRowImages::const_iterator iit = images->begin();
- const MapRowImages::const_iterator iit_end = images->end();
- while (iit != iit_end)
- {
- graphics->drawTileVertexes(*iit);
- ++ iit;
- }
- ++ rit;
- }
- BLOCK_END("MapLayer::drawOGL")
-}
-#endif // USE_OPENGL
-
-void MapLayer::drawSpecialLayer(Graphics *const graphics,
- const int y,
- const int startX,
- const int endX,
- const int scrollX,
- const int scrollY) const restrict
-{
- const int y32 = y * mapTileSize;
- const int py1 = y32 - scrollY;
- int endX1 = endX;
- int specialWidth = mSpecialLayer->mWidth;
- int ptr = y * specialWidth;
- if (endX1 > specialWidth)
- endX1 = specialWidth;
- if (endX1 < 0)
- endX1 = 0;
- int x0 = startX;
- const MapItem *item0 = mSpecialLayer->mTiles[ptr + startX];
- if ((item0 == nullptr) || item0->mType == MapItemType::EMPTY)
- {
- x0 += mSpecialLayer->mCache[ptr + startX] + 1;
- }
- for (int x = x0; x < endX1; x++)
- {
- const int px1 = x * mapTileSize - scrollX;
- const MapItem *const item = mSpecialLayer->mTiles[ptr + x];
- if (item != nullptr)
- {
- item->draw(graphics, px1, py1,
- mapTileSize, mapTileSize);
- }
- x += mSpecialLayer->mCache[ptr + x];
- }
-
- x0 = startX;
- specialWidth = mTempLayer->mWidth;
- ptr = y * specialWidth;
- endX1 = endX;
- if (endX1 > specialWidth)
- endX1 = specialWidth;
- item0 = mTempLayer->mTiles[ptr + startX];
- if ((item0 == nullptr) || item0->mType == MapItemType::EMPTY)
- {
- x0 += mTempLayer->mCache[ptr + startX] + 1;
- }
- for (int x = x0; x < endX1; x++)
- {
- const int px1 = x * mapTileSize - scrollX;
- const MapItem *const item = mTempLayer->mTiles[ptr + x];
- item->draw(graphics, px1, py1,
- mapTileSize, mapTileSize);
- x += mTempLayer->mCache[ptr + x];
- }
-}
-
-void MapLayer::drawFringe(Graphics *const graphics,
- int startX,
- int startY,
- int endX,
- int endY,
- const int scrollX,
- const int scrollY,
- const Actors &actors) const restrict
-{
- BLOCK_START("MapLayer::drawFringe")
- if ((localPlayer == nullptr) ||
- (mSpecialLayer == nullptr) ||
- (mTempLayer == nullptr))
- {
- BLOCK_END("MapLayer::drawFringe")
- return;
- }
-
- startX -= mX;
- startY -= mY;
- endX -= mX;
- endY -= mY;
-
- if (startX < 0)
- startX = 0;
- if (startY < 0)
- startY = 0;
- if (endX > mWidth)
- endX = mWidth;
- if (endY > mHeight)
- endY = mHeight;
-
- ActorsCIter ai = actors.begin();
- const ActorsCIter ai_end = actors.end();
-
- const int dx = mPixelX - scrollX;
- const int dy = mPixelY - scrollY;
-
- const int specialHeight = mSpecialLayer->mHeight;
-
- const bool flag = mDrawLayerFlags == MapType::SPECIAL3 ||
- mDrawLayerFlags == MapType::SPECIAL4 ||
- mDrawLayerFlags == MapType::BLACKWHITE;
-
- const int minEndY = std::min(specialHeight, endY);
-
- if (flag)
- { // flag
- for (int y = startY; y < minEndY; y ++)
- {
- const int y32s = (y + mActorsFix) * mapTileSize;
-
- BLOCK_START("MapLayer::drawFringe drawmobs")
- // If drawing the fringe layer, make sure all actors above this
- // row of tiles have been drawn
- while (ai != ai_end && (*ai)->getSortPixelY() <= y32s)
- {
- (*ai)->draw(graphics, -scrollX, -scrollY);
- ++ ai;
- }
- BLOCK_END("MapLayer::drawFringe drawmobs")
-
- // remove this condition, because it always true
- if (y < specialHeight)
- {
- drawSpecialLayer(graphics,
- y,
- startX,
- endX,
- scrollX,
- scrollY);
- }
- }
-
- for (int y = minEndY; y < endY; y++)
- {
- const int y32s = (y + mActorsFix) * mapTileSize;
-
- BLOCK_START("MapLayer::drawFringe drawmobs")
- // If drawing the fringe layer, make sure all actors above this
- // row of tiles have been drawn
- while (ai != ai_end && (*ai)->getSortPixelY() <= y32s)
- {
- (*ai)->draw(graphics, -scrollX, -scrollY);
- ++ ai;
- }
- BLOCK_END("MapLayer::drawFringe drawmobs")
- }
- }
- else
- { // !flag
- for (int y = startY; y < minEndY; y ++)
- {
- const int y32 = y * mapTileSize;
- const int y32s = (y + mActorsFix) * mapTileSize;
- const int yWidth = y * mWidth;
-
- BLOCK_START("MapLayer::drawFringe drawmobs")
- // If drawing the fringe layer, make sure all actors above this
- // row of tiles have been drawn
- while (ai != ai_end &&
- (*ai)->getSortPixelY() <= y32s)
- {
- (*ai)->draw(graphics, -scrollX, -scrollY);
- ++ ai;
- }
- BLOCK_END("MapLayer::drawFringe drawmobs")
-
- const int py0 = y32 + dy;
-
- int x0 = startX;
- TileInfo *tilePtr = &mTiles[CAST_SIZE(x0 + yWidth)];
- if (tilePtr->isEnabled == false)
- {
- drawSpecialLayer(graphics,
- y,
- 0,
- std::min(x0 + tilePtr->nextTile + 1, endX),
- scrollX,
- scrollY);
- if (x0 + tilePtr->nextTile + 1 >= endX)
- {
- continue;
- }
- x0 += tilePtr->nextTile + 1;
- tilePtr = &mTiles[CAST_SIZE(x0 + yWidth)];
- if (mTiles[x0 + yWidth].isEnabled == false)
- continue;
- }
- for (int x = x0; x < endX; x++, tilePtr++)
- {
- const int x32 = x * mapTileSize;
- const Image *const img = tilePtr->image;
- if (mSpecialFlag ||
- img->mBounds.h <= mapTileSize)
- {
- const int px = x32 + dx;
- const int py = py0 - img->mBounds.h;
-
- if (tilePtr->count == 0)
- {
- graphics->drawImage(img, px, py);
- }
- else
- {
- graphics->drawPattern(img,
- px,
- py,
- tilePtr->width,
- img->mBounds.h);
- }
- }
-
- const int nextTile = tilePtr->nextTile;
- // remove this condition, because it always true
- if (y < specialHeight)
- {
- drawSpecialLayer(graphics,
- y,
- x,
- std::min(x + nextTile + 1, endX),
- scrollX,
- scrollY);
- }
- x += nextTile;
- tilePtr += nextTile;
- }
- }
-
- for (int y = minEndY; y < endY; y++)
- {
- const int y32 = y * mapTileSize;
- const int y32s = (y + mActorsFix) * mapTileSize;
- const int yWidth = y * mWidth;
-
- BLOCK_START("MapLayer::drawFringe drawmobs")
- // If drawing the fringe layer, make sure all actors above this
- // row of tiles have been drawn
- while (ai != ai_end && (*ai)->getSortPixelY() <= y32s)
- {
- (*ai)->draw(graphics, -scrollX, -scrollY);
- ++ ai;
- }
- BLOCK_END("MapLayer::drawFringe drawmobs")
-
- const int py0 = y32 + dy;
-
- int x0 = startX;
- TileInfo *tilePtr = &mTiles[CAST_SIZE(x0 + yWidth)];
- if (tilePtr->isEnabled == false)
- {
- if (x0 + tilePtr->nextTile + 1 >= endX)
- continue;
- x0 += tilePtr->nextTile + 1;
- tilePtr = &mTiles[CAST_SIZE(x0 + yWidth)];
- if (mTiles[x0 + yWidth].isEnabled == false)
- continue;
- }
- for (int x = x0; x < endX; x++, tilePtr++)
- {
- const int x32 = x * mapTileSize;
- const Image *const img = tilePtr->image;
- const int px = x32 + dx;
- const int py = py0 - img->mBounds.h;
- if (mSpecialFlag ||
- img->mBounds.h <= mapTileSize)
- {
- const int c = tilePtr->count;
-
- if (c == 0)
- {
- graphics->drawImage(img, px, py);
- }
- else
- {
- graphics->drawPattern(img,
- px,
- py,
- tilePtr->width,
- img->mBounds.h);
- }
- }
- const int nextTile = tilePtr->nextTile;
- x += nextTile;
- tilePtr += nextTile;
- }
- }
- } // !flag
-
- // Draw any remaining actors
- if (mDrawLayerFlags != MapType::SPECIAL3 &&
- mDrawLayerFlags != MapType::SPECIAL4)
- {
- BLOCK_START("MapLayer::drawFringe drawmobs")
- while (ai != ai_end)
- {
- (*ai)->draw(graphics, -scrollX, -scrollY);
- ++ai;
- }
- BLOCK_END("MapLayer::drawFringe drawmobs")
- if (mHighlightAttackRange)
- {
- const int px = localPlayer->getPixelX()
- - scrollX - mapTileSize / 2;
- const int py = localPlayer->getPixelY() - scrollY - mapTileSize;
- const int attackRange = localPlayer->getAttackRange()
- * mapTileSize;
-
- int x = px - attackRange;
- int y = py - attackRange;
- int w = 2 * attackRange + mapTileSize;
- int h = w;
- if (attackRange <= mapTileSize)
- {
- x -= mapTileSize / 2;
- y -= mapTileSize / 2;
- w += mapTileSize;
- h += mapTileSize;
- }
-
- if (userPalette != nullptr)
- {
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::ATTACK_RANGE));
- graphics->fillRectangle(Rect(x, y, w, h));
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::ATTACK_RANGE_BORDER));
- graphics->drawRectangle(Rect(x, y, w, h));
- }
- }
- }
- BLOCK_END("MapLayer::drawFringe")
-}
-
-int MapLayer::getTileDrawWidth(const TileInfo *restrict tilePtr,
- const int endX,
- int &restrict width,
- int &restrict nextTile)
-{
- BLOCK_START("MapLayer::getTileDrawWidth")
- const Image *const img1 = tilePtr->image;
- int c = 0;
- width = img1->mBounds.w;
- for (int x = 1; x < endX; x++)
- {
- tilePtr ++;
- const Image *const img = tilePtr->image;
- if (img == nullptr ||
- tilePtr->isEnabled == false)
- {
- break;
- }
- if (img != img1)
- {
- nextTile = c;
- BLOCK_END("MapLayer::getTileDrawWidth")
- return c;
- }
- c ++;
- width += img->mBounds.w;
- }
- int c2 = c;
- for (int x2 = c2 + 1; x2 < endX; x2++)
- {
- if (tilePtr->image != nullptr &&
- tilePtr->isEnabled == true)
- {
- break;
- }
- c2 ++;
- tilePtr ++;
- }
- nextTile = c2;
- BLOCK_END("MapLayer::getTileDrawWidth")
- return c;
-}
-
-int MapLayer::getEmptyTileDrawWidth(const TileInfo *restrict tilePtr,
- const int endX,
- int &restrict nextTile)
-{
- BLOCK_START("MapLayer::getEmptyTileDrawWidth")
- int c = 0;
- for (int x = 1; x < endX; x++)
- {
- tilePtr ++;
- const Image *const img = tilePtr->image;
- if (img != nullptr && tilePtr->isEnabled == true)
- break;
- c ++;
- }
- BLOCK_END("MapLayer::getEmptyTileDrawWidth")
-
- nextTile = c;
- return c;
-}
-
-void MapLayer::setDrawLayerFlags(const MapTypeT &n) restrict
-{
- mDrawLayerFlags = n;
- mSpecialFlag = (mDrawLayerFlags != MapType::SPECIAL &&
- mDrawLayerFlags != MapType::SPECIAL2 &&
- mDrawLayerFlags != MapType::SPECIAL4);
-}
-
-void MapLayer::updateConditionTiles(const MetaTile *const metaTiles,
- const int width,
- const int height) restrict
-{
- const int width1 = width < mWidth ? width : mWidth;
- const int height1 = height < mHeight ? height : mHeight;
-
- for (int y = mY; y < height1; y ++)
- {
- const MetaTile *metaPtr = metaTiles + (y - mY) * width;
- TileInfo *tilePtr = mTiles + y * mWidth;
- for (int x = mX; x < width1; x ++, metaPtr ++, tilePtr ++)
- {
- if (tilePtr->image != nullptr &&
- (((metaPtr->blockmask & mTileCondition) != 0) ||
- (metaPtr->blockmask == 0 &&
- mTileCondition == BlockMask::GROUND)))
- {
- tilePtr->isEnabled = true;
- }
- else
- {
- tilePtr->isEnabled = false;
- }
- }
- }
-}
-
-void MapLayer::updateCache(const int width,
- const int height) restrict
-{
- const int width1 = width < mWidth ? width : mWidth;
- const int height1 = height < mHeight ? height : mHeight;
-
- for (int y = mY; y < height1; y ++)
- {
- for (int x = mX; x < width1; x ++)
- {
- TileInfo *tilePtr = mTiles + y * mWidth + x;
- int nextTile = 0;
- if (tilePtr->image == nullptr || tilePtr->isEnabled == false)
- {
- tilePtr->isEnabled = false;
- tilePtr->count = getEmptyTileDrawWidth(tilePtr,
- width1 - x,
- nextTile);
- tilePtr->width = 0;
- }
- else
- {
- int tileWidth = 0;
- tilePtr->count = getTileDrawWidth(tilePtr,
- width1 - x,
- tileWidth,
- nextTile);
- tilePtr->width = tileWidth;
- }
- tilePtr->nextTile = nextTile;
- }
- }
-}
-
-int MapLayer::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(MapLayer) +
- sizeof(TileInfo) * mWidth * mHeight +
- sizeof(MapRowVertexes) * mTempRows.capacity());
-}
-
-int MapLayer::calcMemoryChilds(const int level) const
-{
- int sz = 0;
- if (mSpecialLayer != nullptr)
- sz += mSpecialLayer->calcMemory(level + 1);
- if (mTempLayer != nullptr)
- sz += mTempLayer->calcMemory(level + 1);
- return sz;
-}
diff --git a/src/resources/map/maplayer.h b/src/resources/map/maplayer.h
deleted file mode 100644
index c21ac33bc..000000000
--- a/src/resources/map/maplayer.h
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_MAPLAYER_H
-#define RESOURCES_MAP_MAPLAYER_H
-
-#include "listeners/configlistener.h"
-
-#include "resources/memorycounter.h"
-
-#include "being/actor.h"
-
-#include "enums/resources/map/maptype.h"
-
-#include "utils/vector.h"
-
-#include "resources/map/tileinfo.h"
-
-class Image;
-class MapRowVertexes;
-class SpecialLayer;
-
-struct MetaTile;
-
-/**
- * A map layer. Stores a grid of tiles and their offset, and implements layer
- * rendering.
- */
-class MapLayer final: public MemoryCounter, public ConfigListener
-{
- public:
- friend class Map;
-
- /**
- * Constructor, taking layer origin, size and whether this layer is the
- * fringe layer. The fringe layer is the layer that draws the actors.
- * There can be only one fringe layer per map.
- */
- MapLayer(const std::string &name,
- const int x,
- const int y,
- const int width,
- const int height,
- const bool isFringeLayer,
- const int mask,
- const int tileCondition);
-
- A_DELETE_COPY(MapLayer)
-
- /**
- * Destructor.
- */
- ~MapLayer();
-
- /**
- * Set tile image, with x and y in layer coordinates.
- */
- void setTile(const int x,
- const int y,
- Image *restrict const img) restrict;
-
- /**
- * Set tile image with x + y * width already known.
- */
- void setTile(const int index,
- Image *restrict const img) restrict
- { mTiles[index].image = img; }
-
- /**
- * Draws this layer to the given graphics context. The coordinates are
- * expected to be in map range and will be translated to local layer
- * coordinates and clipped to the layer's dimensions.
- *
- * The given actors are only drawn when this layer is the fringe
- * layer.
- */
- void draw(Graphics *restrict const graphics,
- int startX,
- int startY,
- int endX,
- int endY,
- const int scrollX,
- const int scrollY) const restrict A_NONNULL(2);
-
- void drawSDL(Graphics *restrict const graphics) const restrict2
- A_NONNULL(2);
-
-#ifdef USE_OPENGL
- void drawOGL(Graphics *restrict const graphics) const restrict2
- A_NONNULL(2);
-
- void updateOGL(Graphics *restrict const graphics,
- int startX,
- int startY,
- int endX,
- int endY,
- const int scrollX,
- const int scrollY) restrict2 A_NONNULL(2);
-#endif // USE_OPENGL
-
- void updateSDL(const Graphics *restrict const graphics,
- int startX,
- int startY,
- int endX,
- int endY,
- const int scrollX,
- const int scrollY) restrict2 A_NONNULL(2);
-
- void drawFringe(Graphics *restrict const graphics,
- int startX,
- int startY,
- int endX,
- int endY,
- const int scrollX,
- const int scrollY,
- const Actors &actors) const restrict A_NONNULL(2);
-
- bool isFringeLayer() const restrict noexcept2 A_WARN_UNUSED
- { return mIsFringeLayer; }
-
- void setSpecialLayer(const SpecialLayer *restrict const val) restrict
- { mSpecialLayer = val; }
-
- void setTempLayer(const SpecialLayer *restrict const val) restrict
- { mTempLayer = val; }
-
- int getWidth() const restrict noexcept2 A_WARN_UNUSED
- { return mWidth; }
-
- int getHeight() const restrict noexcept2 A_WARN_UNUSED
- { return mHeight; }
-
- void optionChanged(const std::string &restrict value)
- restrict override final;
-
- void setDrawLayerFlags(const MapTypeT &restrict n) restrict;
-
- void setActorsFix(const int y) restrict
- { mActorsFix = y; }
-
- int calcMemoryLocal() const override final;
-
- int calcMemoryChilds(const int level) const override final;
-
- std::string getCounterName() const override final
- { return mName; }
-
-#ifdef UNITTESTS
- TileInfo *getTiles() const
- {
- return mTiles;
- }
-
- void setTileCondition(const int c)
- {
- mTileCondition = c;
- }
-#endif // UNITTESTS
-
-#ifndef UNITTESTS
- protected:
-#endif // UNITTESTS
- static int getTileDrawWidth(const TileInfo *restrict img,
- const int endX,
- int &restrict width,
- int &restrict nextTile)
- A_WARN_UNUSED A_NONNULL(1);
-
- static int getEmptyTileDrawWidth(const TileInfo *restrict img,
- const int endX,
- int &restrict nextTile)
- A_WARN_UNUSED A_NONNULL(1);
-
- void updateConditionTiles(const MetaTile *restrict const metaTiles,
- const int width,
- const int height) restrict A_NONNULL(2);
-
- void updateCache(const int width,
- const int height) restrict;
-
- void drawSpecialLayer(Graphics *const graphics,
- const int y,
- const int startX,
- const int endX,
- const int scrollX,
- const int scrollY) const restrict;
-
- private:
- const int mX;
- const int mY;
- const int mPixelX;
- const int mPixelY;
- const int mWidth;
- const int mHeight;
- TileInfo *restrict const mTiles;
- MapTypeT mDrawLayerFlags;
- const SpecialLayer *restrict mSpecialLayer;
- const SpecialLayer *restrict mTempLayer;
- const std::string mName;
- typedef STD_VECTOR<MapRowVertexes*> MapRows;
- MapRows mTempRows;
- int mMask;
- int mTileCondition;
- int mActorsFix;
- const bool mIsFringeLayer; /**< Whether the actors are drawn. */
- bool mHighlightAttackRange;
- bool mSpecialFlag;
-};
-
-#endif // RESOURCES_MAP_MAPLAYER_H
diff --git a/src/resources/map/mapobject.h b/src/resources/map/mapobject.h
deleted file mode 100644
index 07b25d3ec..000000000
--- a/src/resources/map/mapobject.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_MAPOBJECT_H
-#define RESOURCES_MAP_MAPOBJECT_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class MapObject final
-{
- public:
- MapObject(const int type0,
- const std::string &data0) :
- type(type0),
- data(data0)
- {
- }
-
- A_DEFAULT_COPY(MapObject)
-
- int type;
- std::string data;
-};
-
-#endif // RESOURCES_MAP_MAPOBJECT_H
diff --git a/src/resources/map/mapobjectlist.h b/src/resources/map/mapobjectlist.h
deleted file mode 100644
index 327c9da9e..000000000
--- a/src/resources/map/mapobjectlist.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_MAPOBJECTLIST_H
-#define RESOURCES_MAP_MAPOBJECTLIST_H
-
-#include "resources/map/mapobject.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class MapObjectList final
-{
- public:
- MapObjectList() :
- objects()
- {
- }
-
- A_DELETE_COPY(MapObjectList)
-
- STD_VECTOR<MapObject> objects;
-};
-
-#endif // RESOURCES_MAP_MAPOBJECTLIST_H
diff --git a/src/resources/map/maprowvertexes.h b/src/resources/map/maprowvertexes.h
deleted file mode 100644
index 0b64bed57..000000000
--- a/src/resources/map/maprowvertexes.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_MAPROWVERTEXES_H
-#define RESOURCES_MAP_MAPROWVERTEXES_H
-
-#include "utils/dtor.h"
-
-#include "render/vertexes/imagevertexes.h"
-
-#include "localconsts.h"
-
-typedef STD_VECTOR<ImageVertexes*> MapRowImages;
-
-class MapRowVertexes final
-{
- public:
- MapRowVertexes() :
- images()
- {
- images.reserve(30);
- }
-
- A_DELETE_COPY(MapRowVertexes)
-
- ~MapRowVertexes()
- {
- delete_all(images);
- images.clear();
- }
-
- MapRowImages images;
-};
-
-#endif // RESOURCES_MAP_MAPROWVERTEXES_H
diff --git a/src/resources/map/metatile.h b/src/resources/map/metatile.h
deleted file mode 100644
index 74cb5f217..000000000
--- a/src/resources/map/metatile.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_METATILE_H
-#define RESOURCES_MAP_METATILE_H
-
-#include "localconsts.h"
-
-/**
- * A meta tile stores additional information about a location on a tile map.
- * This is information that doesn't need to be repeated for each tile in each
- * layer of the map.
- */
-struct MetaTile final
-{
- /**
- * Constructor.
- */
- MetaTile() : Fcost(0), Gcost(0), Hcost(0), whichList(0),
- parentX(0), parentY(0), blockmask(0)
- {}
-
- A_DELETE_COPY(MetaTile)
-
- // Pathfinding members
- int Fcost; /**< Estimation of total path cost */
- int Gcost; /**< Cost from start to this location */
- int Hcost; /**< Estimated cost to goal */
- unsigned whichList; /**< No list, open list or closed list */
- int parentX; /**< X coordinate of parent tile */
- int parentY; /**< Y coordinate of parent tile */
- unsigned char blockmask; /**< Blocking properties of this tile */
-};
-#endif // RESOURCES_MAP_METATILE_H
diff --git a/src/resources/map/objectslayer.cpp b/src/resources/map/objectslayer.cpp
deleted file mode 100644
index 05d00c61e..000000000
--- a/src/resources/map/objectslayer.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/map/objectslayer.h"
-
-#include "utils/cast.h"
-
-#include "resources/map/mapobjectlist.h"
-
-#include "debug.h"
-
-ObjectsLayer::ObjectsLayer(const unsigned width,
- const unsigned height) :
- MemoryCounter(),
- mTiles(new MapObjectList*[width * height]),
- mWidth(width),
- mHeight(height)
-{
- std::fill_n(mTiles, width * height, static_cast<MapObjectList*>(nullptr));
-}
-
-ObjectsLayer::~ObjectsLayer()
-{
- const unsigned size = mWidth * mHeight;
- for (unsigned f = 0; f < size; f ++)
- delete mTiles[f];
-
- delete [] mTiles;
- mTiles = nullptr;
-}
-
-void ObjectsLayer::addObject(const std::string &name, const int type,
- const unsigned x, const unsigned y,
- unsigned dx, unsigned dy)
-{
- if (mTiles == nullptr)
- return;
-
- if (x + dx > mWidth)
- dx = mWidth - x;
- if (y + dy > mHeight)
- dy = mHeight - y;
-
- for (unsigned y1 = y; y1 < y + dy; y1 ++)
- {
- const unsigned idx1 = x + y1 * mWidth;
- const unsigned idx2 = idx1 + dx;
-
- for (unsigned i = idx1; i < idx2; i ++)
- {
- if (mTiles[i] == nullptr)
- mTiles[i] = new MapObjectList;
- mTiles[i]->objects.push_back(MapObject(type, name));
- }
- }
-}
-
-MapObjectList *ObjectsLayer::getAt(const unsigned x, const unsigned y) const
-{
- if (x >= mWidth || y >= mHeight)
- return nullptr;
- return mTiles[x + y * mWidth];
-}
-
-int ObjectsLayer::calcMemoryLocal() const
-{
- return CAST_S32(sizeof(ObjectsLayer) +
- (sizeof(MapObjectList) + sizeof(MapObjectList*)) * mWidth * mHeight);
-}
diff --git a/src/resources/map/objectslayer.h b/src/resources/map/objectslayer.h
deleted file mode 100644
index 3deed3d36..000000000
--- a/src/resources/map/objectslayer.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_OBJECTSLAYER_H
-#define RESOURCES_MAP_OBJECTSLAYER_H
-
-#include "resources/memorycounter.h"
-
-#include "localconsts.h"
-
-class MapObjectList;
-
-class ObjectsLayer final : public MemoryCounter
-{
- public:
- ObjectsLayer(const unsigned width, const unsigned height);
-
- A_DELETE_COPY(ObjectsLayer)
-
- ~ObjectsLayer();
-
- void addObject(const std::string &name, const int type,
- const unsigned x, const unsigned y,
- unsigned dx, unsigned dy);
-
- MapObjectList *getAt(const unsigned x,
- const unsigned y) const A_WARN_UNUSED;
-
- int calcMemoryLocal() const override final;
-
- std::string getCounterName() const override final
- { return "objects layer"; }
-
- private:
- MapObjectList **mTiles;
- unsigned mWidth;
- unsigned mHeight;
-};
-
-#endif // RESOURCES_MAP_OBJECTSLAYER_H
diff --git a/src/resources/map/properties.h b/src/resources/map/properties.h
deleted file mode 100644
index 31d8cfe77..000000000
--- a/src/resources/map/properties.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_PROPERTIES_H
-#define RESOURCES_MAP_PROPERTIES_H
-
-#include "localconsts.h"
-
-#include <map>
-#include <sstream>
-
-/**
- * A class holding a set of properties.
- */
-class Properties notfinal
-{
- public:
- Properties() :
- mProperties()
- {
- }
-
- A_DELETE_COPY(Properties)
-
- /**
- * Destructor.
- */
- virtual ~Properties()
- { }
-
- /**
- * Get a map property.
- *
- * @param name The name of the property.
- * @param def Default value, empty string by default.
- * @return the value of the given property or the given default when it
- * doesn't exist.
- */
- const std::string getProperty(const std::string &name,
- const std::string &def = "")
- const A_WARN_UNUSED
- {
- const PropertyMap::const_iterator i = mProperties.find(name);
- return (i != mProperties.end()) ? i->second : def;
- }
-
- /**
- * Gets a map property as a float.
- *
- * @param name The name of the property.
- * @param def Default value, 0.0F by default.
- * @return the value of the given property or the given default when it
- * doesn't exist.
- */
- float getFloatProperty(const std::string &name,
- const float def = 0.0F) const A_WARN_UNUSED
- {
- const PropertyMap::const_iterator i = mProperties.find(name);
- float ret = def;
- if (i != mProperties.end())
- {
- std::stringstream ss;
- ss.str(i->second);
- ss >> ret;
- }
- return ret;
- }
-
- /**
- * Gets a map property as a boolean.
- *
- * @param name The name of the property.
- * @param def Default value, false by default.
- * @return the value of the given property or the given default when it
- * doesn't exist.
- */
- bool getBoolProperty(const std::string &name,
- const bool def = false) const A_WARN_UNUSED
- {
- const PropertyMap::const_iterator i = mProperties.find(name);
- bool ret = def;
- if (i != mProperties.end())
- {
- if (i->second == "true")
- ret = true;
- if (i->second == "false")
- ret = false;
- }
- return ret;
- }
-
- /**
- * Returns whether a certain property is available.
- *
- * @param name The name of the property.
- * @return <code>true</code> when a property is defined,
- * <code>false</code> otherwise.
- */
- bool hasProperty(const std::string &name) const A_WARN_UNUSED
- { return (mProperties.find(name) != mProperties.end()); }
-
- /**
- * Set a map property.
- *
- * @param name The name of the property.
- * @param value The value of the property.
- */
- void setProperty(const std::string &name, const std::string &value)
- { mProperties[name] = value; }
-
-
- private:
- typedef std::map<std::string, std::string> PropertyMap;
- PropertyMap mProperties;
-};
-
-#endif // RESOURCES_MAP_PROPERTIES_H
diff --git a/src/resources/map/speciallayer.cpp b/src/resources/map/speciallayer.cpp
deleted file mode 100644
index ad186c2d9..000000000
--- a/src/resources/map/speciallayer.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/map/speciallayer.h"
-
-#include "const/resources/map/map.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "resources/map/mapitem.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-SpecialLayer::SpecialLayer(const std::string &name,
- const int width,
- const int height) :
- MemoryCounter(),
- mName(name),
- mTiles(new MapItem*[width * height]),
- mCache(new int[width * height]),
- mWidth(width),
- mHeight(height)
-{
- std::fill_n(mTiles, mWidth * mHeight, static_cast<MapItem*>(nullptr));
- std::fill_n(mCache, mWidth * mHeight, 10000);
-}
-
-SpecialLayer::~SpecialLayer()
-{
- for (int f = 0; f < mWidth * mHeight; f ++)
- delete2(mTiles[f])
- delete [] mTiles;
- delete [] mCache;
-}
-
-MapItem* SpecialLayer::getTile(const int x, const int y) const
-{
- if (x < 0 || x >= mWidth ||
- y < 0 || y >= mHeight)
- {
- return nullptr;
- }
- return mTiles[x + y * mWidth];
-}
-
-void SpecialLayer::setTile(const int x, const int y, MapItem *const item)
-{
- if (x < 0 || x >= mWidth ||
- y < 0 || y >= mHeight)
- {
- return;
- }
-
- const int idx = x + y * mWidth;
- delete mTiles[idx];
- if (item != nullptr)
- item->setPos(x, y);
- mTiles[idx] = item;
-}
-
-void SpecialLayer::setTile(const int x, const int y, const int type)
-{
- if (x < 0 || x >= mWidth ||
- y < 0 || y >= mHeight)
- {
- return;
- }
-
- const int idx = x + y * mWidth;
- MapItem *const tile = mTiles[idx];
- if (tile != nullptr)
- {
- tile->setType(type);
- tile->setPos(x, y);
- }
- else
- {
- mTiles[idx] = new MapItem(type);
- mTiles[idx]->setPos(x, y);
- }
-}
-
-void SpecialLayer::addRoad(const Path &road)
-{
- FOR_EACH (Path::const_iterator, i, road)
- {
- const Position &pos = *i;
- MapItem *const item = getTile(pos.x, pos.y);
- if (item == nullptr)
- setTile(pos.x, pos.y, new MapItem(MapItemType::ROAD));
- else
- item->setType(MapItemType::ROAD);
- }
- updateCache();
-}
-
-void SpecialLayer::clean()
-{
- if (mTiles == nullptr)
- return;
-
- for (int f = 0; f < mWidth * mHeight; f ++)
- {
- MapItem *const item = mTiles[f];
- if (item != nullptr)
- item->setType(MapItemType::EMPTY);
- }
- updateCache();
-}
-
-void SpecialLayer::draw(Graphics *const graphics, int startX, int startY,
- int endX, int endY,
- const int scrollX, const int scrollY) const
-{
- BLOCK_START("SpecialLayer::draw")
- if (startX < 0)
- startX = 0;
- if (startY < 0)
- startY = 0;
- if (endX > mWidth)
- endX = mWidth;
- if (endY > mHeight)
- endY = mHeight;
-
- for (int y = startY; y < endY; y ++)
- {
- const int py = y * mapTileSize - scrollY;
- const int y2 = y * mWidth;
- for (int x = startX; x < endX; x ++)
- {
- const MapItem *const item = mTiles[x + y2];
- if (item != nullptr)
- {
- item->draw(graphics, x * mapTileSize - scrollX, py,
- mapTileSize, mapTileSize);
- }
- }
- }
- BLOCK_END("SpecialLayer::draw")
-}
-
-int SpecialLayer::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(SpecialLayer) +
- sizeof(MapItem) * mWidth * mHeight);
-}
-
-void SpecialLayer::updateCache()
-{
- for (int y = 0; y < mHeight; y ++)
- {
- const int y2 = y * mWidth;
- for (int x = 0; x < mWidth; x ++)
- {
- int c = 10000;
- for (int f = x + 1; f < mWidth; f ++)
- {
- MapItem *const item = mTiles[f + y2];
- if (item != nullptr &&
- item->mType != MapItemType::EMPTY)
- {
- c = f - x - 1;
- break;
- }
- }
- mCache[x + y2] = c;
- }
- }
-}
diff --git a/src/resources/map/speciallayer.h b/src/resources/map/speciallayer.h
deleted file mode 100644
index 8f6f914d3..000000000
--- a/src/resources/map/speciallayer.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_SPECIALLAYER_H
-#define RESOURCES_MAP_SPECIALLAYER_H
-
-#include "resources/memorycounter.h"
-
-#include "position.h"
-
-#include "localconsts.h"
-
-class Graphics;
-class MapItem;
-
-class SpecialLayer final : public MemoryCounter
-{
- public:
- friend class Map;
- friend class MapLayer;
-
- SpecialLayer(const std::string &name,
- const int width,
- const int height);
-
- A_DELETE_COPY(SpecialLayer)
-
- ~SpecialLayer();
-
- void draw(Graphics *const graphics,
- int startX, int startY,
- int endX, int endY,
- const int scrollX, const int scrollY) const A_NONNULL(2);
-
- MapItem* getTile(const int x, const int y) const A_WARN_UNUSED;
-
- void setTile(const int x, const int y, MapItem *const item);
-
- void setTile(const int x, const int y, const int type);
-
- void addRoad(const Path &road);
-
- void clean();
-
- int calcMemoryLocal() const override final;
-
- std::string getCounterName() const override final
- { return mName; }
-
- void updateCache();
-
-#ifdef UNITTESTS
- const int *getCache() const
- { return mCache; }
-
- MapItem **getTiles() const
- { return mTiles; }
-#endif // UNITTESTS
-
- private:
- const std::string mName;
- MapItem **mTiles;
- int *mCache;
- int mWidth;
- int mHeight;
-};
-
-#endif // RESOURCES_MAP_SPECIALLAYER_H
diff --git a/src/resources/map/tileanimation.cpp b/src/resources/map/tileanimation.cpp
deleted file mode 100644
index fee4ef150..000000000
--- a/src/resources/map/tileanimation.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/map/tileanimation.h"
-
-#include "resources/animation/simpleanimation.h"
-
-#include "resources/map/maplayer.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-TileAnimation::TileAnimation(Animation *const ani) :
- mAffected(),
- mAnimation(new SimpleAnimation(ani)),
- mLastImage(nullptr)
-{
-}
-
-TileAnimation::~TileAnimation()
-{
- delete2(mAnimation);
-}
-
-bool TileAnimation::update(const int ticks)
-{
- if (mAnimation == nullptr)
- return false;
-
- // update animation
- if (!mAnimation->update(ticks))
- return false;
-
- // exchange images
- Image *const img = mAnimation->getCurrentImage();
- if (img != mLastImage)
- {
- FOR_EACH (TilePairVectorCIter, i, mAffected)
- {
- if (i->first != nullptr)
- i->first->setTile(i->second, img);
- }
- mLastImage = img;
- }
- return true;
-}
diff --git a/src/resources/map/tileanimation.h b/src/resources/map/tileanimation.h
deleted file mode 100644
index a9b5cc281..000000000
--- a/src/resources/map/tileanimation.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_TILEANIMATION_H
-#define RESOURCES_MAP_TILEANIMATION_H
-
-#include "utils/vector.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-class Animation;
-class Image;
-class MapLayer;
-class SimpleAnimation;
-
-typedef STD_VECTOR<std::pair<MapLayer*, int> > TilePairVector;
-typedef TilePairVector::const_iterator TilePairVectorCIter;
-
-/**
- * Animation cycle of a tile image which changes the map accordingly.
- */
-class TileAnimation final
-{
- public:
- explicit TileAnimation(Animation *const ani);
-
- ~TileAnimation();
-
- A_DELETE_COPY(TileAnimation)
-
- bool update(const int ticks = 1);
-
- void addAffectedTile(MapLayer *const layer, const int index)
- { mAffected.push_back(std::make_pair(layer, index)); }
-
- private:
- TilePairVector mAffected;
- SimpleAnimation *mAnimation;
- Image *mLastImage;
-};
-
-typedef std::map<int, TileAnimation*> TileAnimationMap;
-typedef TileAnimationMap::const_iterator TileAnimationMapCIter;
-
-#endif // RESOURCES_MAP_TILEANIMATION_H
diff --git a/src/resources/map/tileinfo.h b/src/resources/map/tileinfo.h
deleted file mode 100644
index bb92be4fc..000000000
--- a/src/resources/map/tileinfo.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2015-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_TILEINFO_H
-#define RESOURCES_MAP_TILEINFO_H
-
-#include "localconsts.h"
-
-class Image;
-
-struct TileInfo final
-{
- TileInfo() :
- image(nullptr),
- width(0),
- count(1),
- nextTile(1),
- isEnabled(true)
- {
- }
-
- A_DELETE_COPY(TileInfo)
-
- /* tile image */
- Image *image;
- /* repeated tile width in pixels */
- int width;
- /* repeated tiles count - 1 */
- int count;
- /* number of tiles to get next tile */
- int nextTile;
- /* is tile enabled flag. if set to true, also mean image is non null */
- bool isEnabled;
-};
-
-#endif // RESOURCES_MAP_TILEINFO_H
diff --git a/src/resources/map/tileset.h b/src/resources/map/tileset.h
deleted file mode 100644
index 942a18b51..000000000
--- a/src/resources/map/tileset.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_TILESET_H
-#define RESOURCES_MAP_TILESET_H
-
-#include "resources/imageset.h"
-
-#include <map>
-
-/**
- * A tileset, which is basically just an image set but it stores a firstgid.
- */
-class Tileset final : public ImageSet
-{
- public:
- /**
- * Constructor.
- */
- Tileset(Image *const img,
- const int w,
- const int h,
- const int firstGid,
- const int margin,
- const int spacing) :
- ImageSet(img, w, h, margin, spacing),
- mFirstGid(firstGid),
- mProperties()
- {
- }
-
- A_DELETE_COPY(Tileset)
-
- /**
- * Returns the first gid.
- */
- int getFirstGid() const noexcept2 A_WARN_UNUSED
- { return mFirstGid; }
-
- /**
- * Set tileset property.
- */
- void setProperties(const std::map<std::string,
- std::string> &props) noexcept2
- { mProperties = props; }
-
- /**
- * Returns property value.
- */
- std::string getProperty(const std::string &name) A_WARN_UNUSED
- {
- const std::map<std::string, std::string>::const_iterator
- it = mProperties.find(name);
- if (it == mProperties.end())
- return "";
- return mProperties[name];
- }
-
- int calcMemoryLocal() const override final
- {
- int sz = ImageSet::calcMemoryLocal() +
- static_cast<int>(sizeof(Tileset));
- const std::map<std::string, std::string>::const_iterator it_end =
- mProperties.end();
- std::map<std::string, std::string>::const_iterator it =
- mProperties.begin();
- while (it != it_end)
- {
- sz += static_cast<int>((*it).first.capacity() +
- (*it).second.capacity());
- ++ it;
- }
- return sz;
- }
-
- private:
- int mFirstGid;
-
- std::map<std::string, std::string> mProperties;
-};
-
-#endif // RESOURCES_MAP_TILESET_H
diff --git a/src/resources/map/walklayer.cpp b/src/resources/map/walklayer.cpp
deleted file mode 100644
index 04b6a3cff..000000000
--- a/src/resources/map/walklayer.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/map/walklayer.h"
-
-#include "debug.h"
-
-WalkLayer::WalkLayer(const int width, const int height) :
- Resource(),
- mWidth(width),
- mHeight(height),
- mTiles(new int[width * height])
-{
- std::fill_n(mTiles, width * height, 0);
-}
-
-WalkLayer::~WalkLayer()
-{
- delete [] mTiles;
-}
-
-int WalkLayer::getDataAt(const int x, const int y) const
-{
- if (x < 0 || x >= mWidth || y < 0 || y >= mHeight)
- return 0;
- return mTiles[x + y * mWidth];
-}
-
-int WalkLayer::calcMemoryLocal() const
-{
- return Resource::calcMemoryLocal() +
- static_cast<int>(sizeof(WalkLayer) +
- sizeof(int) * mWidth * mHeight);
-}
diff --git a/src/resources/map/walklayer.h b/src/resources/map/walklayer.h
deleted file mode 100644
index 4e5cc9c65..000000000
--- a/src/resources/map/walklayer.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAP_WALKLAYER_H
-#define RESOURCES_MAP_WALKLAYER_H
-
-#include "resources/resource.h"
-
-#include "localconsts.h"
-
-class WalkLayer final : public Resource
-{
- public:
- WalkLayer(const int width, const int height);
-
- A_DELETE_COPY(WalkLayer)
-
- ~WalkLayer();
-
- int *getData()
- { return mTiles; }
-
- int getDataAt(const int x, const int y) const;
-
- int calcMemoryLocal() const override final;
-
- std::string getCounterName() const override final
- { return "walk layer"; }
-
- private:
- int mWidth;
- int mHeight;
- int *mTiles;
-};
-
-#endif // RESOURCES_MAP_WALKLAYER_H
diff --git a/src/resources/mapinfo.h b/src/resources/mapinfo.h
deleted file mode 100644
index 65926c757..000000000
--- a/src/resources/mapinfo.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Aethyra Development Team
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAPINFO_H
-#define RESOURCES_MAPINFO_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-struct MapInfo final
-{
- MapInfo() :
- atlas(),
- files(nullptr)
- {
- }
-
- A_DEFAULT_COPY(MapInfo)
-
- std::string atlas;
- const StringVect *files;
-};
-
-#endif // RESOURCES_MAPINFO_H
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
deleted file mode 100644
index 4d0b89b3a..000000000
--- a/src/resources/mapreader.cpp
+++ /dev/null
@@ -1,1324 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/mapreader.h"
-
-#include "configuration.h"
-#ifdef USE_OPENGL
-#include "graphicsmanager.h"
-#endif // USE_OPENGL
-#include "main.h"
-
-#include "const/resources/map/map.h"
-
-#include "enums/resources/map/collisiontype.h"
-#include "enums/resources/map/mapitemtype.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "resources/map/map.h"
-#include "resources/map/mapheights.h"
-#include "resources/map/maplayer.h"
-#include "resources/map/tileset.h"
-
-#include "resources/beingcommon.h"
-#include "resources/animation/animation.h"
-
-#include "resources/image/image.h"
-
-#ifdef USE_OPENGL
-#include "resources/db/mapdb.h"
-#include "resources/loaders/atlasloader.h"
-#include "resources/loaders/emptyatlasloader.h"
-#endif // USE_OPENGL
-
-#include "resources/map/tileanimation.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "resources/loaders/walklayerloader.h"
-
-#include "utils/base64.h"
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/stringmap.h"
-
-#include "utils/translation/podict.h"
-
-#include <zlib.h>
-
-#include "debug.h"
-
-typedef std::map<std::string, XmlNodePtr>::iterator LayerInfoIterator;
-typedef std::set<XML::Document*>::iterator DocIterator;
-
-#ifdef USE_OPENGL
-Resource *MapReader::mEmptyAtlas = nullptr;
-#endif // USE_OPENGL
-
-namespace
-{
- std::map<std::string, XmlNodePtr> mKnownLayers;
- std::set<XML::Document*> mKnownDocs;
-} // namespace
-
-static int inflateMemory(unsigned char *restrict const in,
- const unsigned int inLength,
- unsigned char *&restrict out,
- unsigned int &restrict outLength);
-
-static int inflateMemory(unsigned char *restrict const in,
- const unsigned int inLength,
- unsigned char *&restrict out);
-
-static std::string resolveRelativePath(std::string base, std::string relative)
-{
- // Remove trailing "/", if present
- size_t i = base.length();
- if (base.at(i - 1) == '/')
- base.erase(i - 1, i);
-
- while (relative.substr(0, 3) == "../")
- {
- relative.erase(0, 3); // Remove "../"
- if (!base.empty()) // If base is already empty, we can't trim anymore
- {
- i = base.find_last_of('/');
- if (i == std::string::npos)
- i = 0;
- base.erase(i, base.length()); // Remove deepest folder in base
- }
- }
-
- // Re-add trailing slash, if needed
- if (!base.empty() && base[base.length() - 1] != '/')
- base.append("/");
-
- return base + relative;
-}
-
-/**
- * Inflates either zlib or gzip deflated memory. The inflated memory is
- * expected to be freed by the caller.
- */
-int inflateMemory(unsigned char *restrict const in,
- const unsigned int inLength,
- unsigned char *&restrict out,
- unsigned int &restrict outLength)
-{
- int bufferSize = 256 * 1024;
- out = static_cast<unsigned char*>(calloc(bufferSize, 1));
-
- z_stream strm;
- strm.zalloc = nullptr;
- strm.zfree = nullptr;
- strm.opaque = nullptr;
- strm.next_in = in;
- strm.avail_in = inLength;
- strm.next_out = out;
- strm.avail_out = bufferSize;
-
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
- int ret = inflateInit2(&strm, 15 + 32);
-PRAGMACLANG6GCC(GCC diagnostic pop)
-
- if (ret != Z_OK)
- return ret;
-
- do
- {
- if (strm.next_out == nullptr)
- {
- inflateEnd(&strm);
- return Z_MEM_ERROR;
- }
-
- ret = inflate(&strm, Z_NO_FLUSH);
- if (ret == Z_STREAM_ERROR)
- return ret;
-
- switch (ret)
- {
- case Z_NEED_DICT:
- ret = Z_DATA_ERROR;
- A_FALLTHROUGH
- case Z_DATA_ERROR:
- case Z_MEM_ERROR:
- (void) inflateEnd(&strm);
- return ret;
- default:
- break;
- }
-
- if (ret != Z_STREAM_END)
- {
- out = static_cast<unsigned char*>(realloc(out, bufferSize * 2));
-
- if (out == nullptr)
- {
- inflateEnd(&strm);
- return Z_MEM_ERROR;
- }
-
- strm.next_out = out + CAST_SIZE(bufferSize);
- strm.avail_out = bufferSize;
- bufferSize *= 2;
- }
- }
- while (ret != Z_STREAM_END);
-
- outLength = bufferSize - strm.avail_out;
- (void) inflateEnd(&strm);
- return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
-}
-
-int inflateMemory(unsigned char *restrict const in,
- const unsigned int inLength,
- unsigned char *&restrict out)
-{
- unsigned int outLength = 0;
- const int ret = inflateMemory(in, inLength, out, outLength);
-
- if (ret != Z_OK || (out == nullptr))
- {
- if (ret == Z_MEM_ERROR)
- {
- reportAlways("Error: Out of memory while decompressing map data!");
- }
- else if (ret == Z_VERSION_ERROR)
- {
- reportAlways("Error: Incompatible zlib version!");
- }
- else if (ret == Z_DATA_ERROR)
- {
- reportAlways("Error: Incorrect zlib compressed data!");
- }
- else
- {
- reportAlways("Error: Unknown error while decompressing map data!");
- }
-
- free(out);
- out = nullptr;
- outLength = 0;
- }
-
- return outLength;
-}
-
-void MapReader::addLayerToList(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document *doc = new XML::Document(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodePtrConst node = doc->rootNode();
- if (node == nullptr)
- {
- delete doc;
- return;
- }
-
- int cnt = 0;
- for_each_xml_child_node(childNode, node)
- {
- if (!xmlNameEqual(childNode, "layer"))
- continue;
- std::string name = XML::getProperty(childNode, "name", "");
- if (name.empty())
- continue;
- name = toLower(name);
- logger->log("found patch layer: " + name);
- mKnownLayers[name] = childNode;
- mKnownDocs.insert(doc);
- cnt ++;
- }
- if (cnt == 0)
- delete doc;
-}
-
-Map *MapReader::readMap(const std::string &restrict filename,
- const std::string &restrict realFilename)
-{
- BLOCK_START("MapReader::readMap str")
- logger->log("Attempting to read map %s", realFilename.c_str());
-
- XML::Document doc(realFilename, UseVirtFs_true, SkipError_false);
- if (!doc.isLoaded())
- {
- BLOCK_END("MapReader::readMap str")
- return createEmptyMap(filename, realFilename);
- }
-
- XmlNodePtrConst node = doc.rootNode();
-
- Map *map = nullptr;
- // Parse the inflated map data
- if (node != nullptr)
- {
- if (!xmlNameEqual(node, "map"))
- logger->log("Error: Not a map file (%s)!", realFilename.c_str());
- else
- map = readMap(node, realFilename);
- }
- else
- {
- reportAlways("Error while parsing map file (%s)!",
- realFilename.c_str());
- }
-
- if (map != nullptr)
- {
- map->setProperty("_filename", realFilename);
- map->setProperty("_realfilename", filename);
-
- if (map->getProperty("music").empty())
- updateMusic(map);
-
- map->updateConditionLayers();
- map->preCacheLayers();
- }
-
- BLOCK_END("MapReader::readMap str")
- return map;
-}
-
-void MapReader::loadLayers(const std::string &path)
-{
- BLOCK_START("MapReader::loadLayers")
- loadXmlDir2(path, addLayerToList, ".tmx", SkipError_false);
- BLOCK_END("MapReader::loadLayers")
-}
-
-void MapReader::unloadTempLayers()
-{
- FOR_EACH (DocIterator, it, mKnownDocs)
- delete (*it);
- mKnownLayers.clear();
- mKnownDocs.clear();
-}
-
-static void loadReplaceLayer(const LayerInfoIterator &it,
- Map *const map) A_NONNULL(2);
-static void loadReplaceLayer(const LayerInfoIterator &it,
- Map *const map)
-{
- MapReader::readLayer((*it).second, map);
-}
-
-Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
-{
- if (node == nullptr)
- return nullptr;
-
- BLOCK_START("MapReader::readMap xml")
- // Take the filename off the path
- const std::string pathDir = path.substr(0, path.rfind('/') + 1);
-
- const int w = XML::getProperty(node, "width", 0);
- const int h = XML::getProperty(node, "height", 0);
- const int tilew = XML::getProperty(node, "tilewidth", -1);
- const int tileh = XML::getProperty(node, "tileheight", -1);
-
- const bool showWarps = config.getBoolValue("warpParticle");
- const std::string warpPath = pathJoin(paths.getStringValue("particles"),
- paths.getStringValue("portalEffectFile"));
-
- if (tilew < 0 || tileh < 0)
- {
- reportAlways("MapReader: Warning: "
- "Uninitialized tile width or height value for map: %s",
- path.c_str());
- BLOCK_END("MapReader::readMap xml")
- return nullptr;
- }
-
- logger->log("loading replace layer list");
- loadLayers(path + "_replace.d");
-
- Map *const map = new Map(path,
- w, h,
- tilew, tileh);
-
- const std::string fileName = path.substr(path.rfind(dirSeparator) + 1);
- map->setProperty("shortName", fileName);
-
-#ifdef USE_OPENGL
- BLOCK_START("MapReader::readMap load atlas")
- if (graphicsManager.getUseAtlases())
- {
- const MapInfo *const info = MapDB::getMapAtlas(fileName);
- if (info != nullptr)
- {
- map->setAtlas(Loader::getAtlas(
- info->atlas,
- *info->files));
- }
- else
- {
- reportAlways("Missing atlas for map: %s",
- fileName.c_str());
- }
- }
- BLOCK_END("MapReader::readMap load atlas")
-#endif // USE_OPENGL
-
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "tileset"))
- {
- Tileset *const tileset = readTileset(childNode, pathDir, map);
- if (tileset != nullptr)
- map->addTileset(tileset);
- }
- else if (xmlNameEqual(childNode, "layer"))
- {
- std::string name = XML::getProperty(childNode, "name", "");
- name = toLower(name);
- LayerInfoIterator it = mKnownLayers.find(name);
- if (it == mKnownLayers.end())
- {
- readLayer(childNode, map);
- }
- else
- {
- logger->log("load replace layer: " + name);
- loadReplaceLayer(it, map);
- }
- }
- else if (xmlNameEqual(childNode, "properties"))
- {
- readProperties(childNode, map);
- map->setVersion(atoi(map->getProperty(
- "manaplus version").c_str()));
- }
- else if (xmlNameEqual(childNode, "objectgroup"))
- {
- // The object group offset is applied to each object individually
- const int tileOffsetX = XML::getProperty(childNode, "x", 0);
- const int tileOffsetY = XML::getProperty(childNode, "y", 0);
- const int offsetX = tileOffsetX * tilew;
- const int offsetY = tileOffsetY * tileh;
- const bool showParticles =
- config.getBoolValue("mapparticleeffects");
-
- for_each_xml_child_node(objectNode, childNode)
- {
- if (xmlNameEqual(objectNode, "object"))
- {
- std::string objType = XML::getProperty(
- objectNode, "type", "");
-
- objType = toUpper(objType);
-
-/*
- if (objType == "NPC" ||
- objType == "SCRIPT")
- {
- logger->log("hidden obj: " + objType);
- // Silently skip server-side objects.
- continue;
- }
-*/
-
- const std::string objName = XML::getProperty(
- objectNode, "name", "");
- const int objX = XML::getProperty(objectNode, "x", 0);
- const int objY = XML::getProperty(objectNode, "y", 0);
- const int objW = XML::getProperty(objectNode, "width", 0);
- const int objH = XML::getProperty(objectNode, "height", 0);
-
- logger->log("- Loading object name: %s type: %s at %d:%d"
- " (%dx%d)", objName.c_str(), objType.c_str(),
- objX, objY, objW, objH);
-
- if (objType == "PARTICLE_EFFECT")
- {
- if (objName.empty())
- {
- logger->log1(" Warning: No particle file given");
- continue;
- }
-
- if (showParticles)
- {
- map->addParticleEffect(objName,
- objX + offsetX,
- objY + offsetY,
- objW,
- objH);
- }
- else
- {
- logger->log("Ignore particle effect: " + objName);
- }
- }
- else if (objType == "WARP")
- {
- if (showWarps)
- {
- map->addParticleEffect(warpPath,
- objX, objY, objW, objH);
- }
- map->addPortal(objName, MapItemType::PORTAL,
- objX, objY, objW, objH);
- }
- else if (objType == "SPAWN")
- {
- // TRANSLATORS: spawn name
-// map->addPortal(_("Spawn: ") + objName,
-// MapItemType::PORTAL,
-// objX, objY, objW, objH);
- }
- else if (objType == "MUSIC")
- {
- map->addRange(objName, MapItemType::MUSIC,
- objX, objY, objW, objH);
- }
- else
- {
- logger->log1(" Warning: Unknown object type");
- }
- }
- }
- }
- }
-
- map->initializeAmbientLayers();
- map->clearIndexedTilesets();
- map->setActorsFix(0, atoi(map->getProperty("actorsfix").c_str()));
- map->reduce();
- map->setWalkLayer(Loader::getWalkLayer(fileName, map));
- unloadTempLayers();
- map->updateDrawLayersList();
- BLOCK_END("MapReader::readMap xml")
- return map;
-}
-
-void MapReader::readProperties(XmlNodeConstPtrConst node,
- Properties *const props)
-{
- BLOCK_START("MapReader::readProperties")
- if (node == nullptr)
- {
- BLOCK_END("MapReader::readProperties")
- return;
- }
-
- for_each_xml_child_node(childNode, node)
- {
- if (!xmlNameEqual(childNode, "property"))
- continue;
-
- // Example: <property name="name" value="value"/>
- const std::string name = XML::getProperty(childNode, "name", "");
- const std::string value = XML::getProperty(childNode, "value", "");
-
- if (!name.empty() && !value.empty())
- {
- if (name == "name")
- props->setProperty(name, translator->getStr(value));
- else
- props->setProperty(name, value);
- }
- }
- BLOCK_END("MapReader::readProperties")
-}
-
-inline static void setTile(Map *const map,
- MapLayer *const layer,
- const MapLayerTypeT &layerType,
- MapHeights *const heights,
- const int x, const int y,
- const int gid) A_NONNULL(1);
-
-inline static void setTile(Map *const map,
- MapLayer *const layer,
- const MapLayerTypeT &layerType,
- MapHeights *const heights,
- const int x, const int y,
- const int gid)
-{
- const Tileset * const set = map->getTilesetWithGid(gid);
- switch (layerType)
- {
- case MapLayerType::TILES:
- {
- Image *const img = set != nullptr ?
- set->get(gid - set->getFirstGid()) : nullptr;
- if (layer != nullptr)
- layer->setTile(x, y, img);
- break;
- }
-
- case MapLayerType::COLLISION:
- {
- if (set != nullptr)
- {
- if (map->getVersion() >= 1)
- {
- const int collisionId = gid - set->getFirstGid();
- CollisionTypeT type;
- if (collisionId < 0 ||
- collisionId >= CAST_S32(CollisionType::COLLISION_MAX))
- {
- type = CollisionType::COLLISION_EMPTY;
- }
- else
- {
- type = static_cast<CollisionTypeT>(collisionId);
- }
- switch (type)
- {
- case CollisionType::COLLISION_EMPTY:
- map->addBlockMask(x, y, BlockType::GROUND);
- break;
- case CollisionType::COLLISION_WALL:
- map->addBlockMask(x, y, BlockType::WALL);
- break;
- case CollisionType::COLLISION_AIR:
- map->addBlockMask(x, y, BlockType::AIR);
- break;
- case CollisionType::COLLISION_WATER:
- map->addBlockMask(x, y, BlockType::WATER);
- break;
- case CollisionType::COLLISION_GROUNDTOP:
- map->addBlockMask(x, y, BlockType::GROUNDTOP);
- break;
- case CollisionType::COLLISION_PLAYER_WALL:
- map->addBlockMask(x, y, BlockType::PLAYERWALL);
- break;
- case CollisionType::COLLISION_MONSTER_WALL:
- map->addBlockMask(x, y, BlockType::MONSTERWALL);
- break;
- case CollisionType::COLLISION_MAX:
- default:
- break;
- }
- }
- else
- {
- if (gid - set->getFirstGid() != 0)
- map->addBlockMask(x, y, BlockType::WALL);
- }
- }
- break;
- }
-
- case MapLayerType::HEIGHTS:
- {
- if (set == nullptr || heights == nullptr)
- break;
- if (map->getVersion() >= 2)
- {
- heights->setHeight(x, y, CAST_U8(
- gid - set->getFirstGid() + 1));
- }
- else
- {
- Image *const img = set->get(gid - set->getFirstGid());
- if (layer != nullptr)
- layer->setTile(x, y, img);
- }
- break;
- }
-
- default:
- case MapLayerType::ACTIONS:
- break;
- }
-}
-
-bool MapReader::readBase64Layer(XmlNodeConstPtrConst childNode,
- Map *const map,
- MapLayer *const layer,
- const MapLayerTypeT &layerType,
- MapHeights *const heights,
- const std::string &compression,
- int &restrict x, int &restrict y,
- const int w, const int h)
-{
- if (childNode == nullptr)
- return false;
-
- if (!compression.empty() && compression != "gzip"
- && compression != "zlib")
- {
- reportAlways("Warning: only gzip and zlib layer"
- " compression supported!");
- return false;
- }
-
- // Read base64 encoded map file
- if (!XmlHaveChildContent(childNode))
- return true;
-
- const size_t len = strlen(XmlChildContent(childNode)) + 1;
- unsigned char *charData = new unsigned char[len + 1];
- const char *const xmlChars = XmlChildContent(childNode);
- const char *charStart = reinterpret_cast<const char*>(xmlChars);
- if (charStart == nullptr)
- {
- delete [] charData;
- return false;
- }
-
- unsigned char *charIndex = charData;
-
- while (*charStart != 0)
- {
- if (*charStart != ' ' &&
- *charStart != '\t' &&
- *charStart != '\n')
- {
- *charIndex = *charStart;
- charIndex++;
- }
- charStart++;
- }
- *charIndex = '\0';
-
- int binLen;
- unsigned char *binData = php3_base64_decode(charData,
- CAST_S32(strlen(reinterpret_cast<char*>(
- charData))), &binLen);
-
- delete [] charData;
-// XmlFree(const_cast<char*>(xmlChars));
-
- if (binData != nullptr)
- {
- if (compression == "gzip" || compression == "zlib")
- {
- // Inflate the gzipped layer data
- unsigned char *inflated = nullptr;
- const unsigned int inflatedSize =
- inflateMemory(binData, binLen, inflated);
-
- free(binData);
- binData = inflated;
- binLen = inflatedSize;
-
- if (inflated == nullptr)
- {
- reportAlways("Error: Could not decompress layer!");
- return false;
- }
- }
-
- const std::map<int, TileAnimation*> &tileAnimations
- = map->getTileAnimations();
-
- const bool hasAnimations = !tileAnimations.empty();
- if (hasAnimations)
- {
- for (int i = 0; i < binLen - 3; i += 4)
- {
- const int gid = binData[i] |
- binData[i + 1] << 8 |
- binData[i + 2] << 16 |
- binData[i + 3] << 24;
-
- setTile(map, layer, layerType, heights, x, y, gid);
- TileAnimationMapCIter it = tileAnimations.find(gid);
- if (it != tileAnimations.end())
- {
- TileAnimation *const ani = it->second;
- if (ani != nullptr)
- ani->addAffectedTile(layer, x + y * w);
- }
-
- x++;
- if (x == w)
- {
- x = 0; y++;
-
- // When we're done, don't crash on too much data
- if (y == h)
- break;
- }
- }
- }
- else
- {
- for (int i = 0; i < binLen - 3; i += 4)
- {
- const int gid = binData[i] |
- binData[i + 1] << 8 |
- binData[i + 2] << 16 |
- binData[i + 3] << 24;
-
- setTile(map, layer, layerType, heights, x, y, gid);
-
- x++;
- if (x == w)
- {
- x = 0; y++;
-
- // When we're done, don't crash on too much data
- if (y == h)
- break;
- }
- }
- }
- free(binData);
- }
- return true;
-}
-
-bool MapReader::readCsvLayer(XmlNodeConstPtrConst childNode,
- Map *const map,
- MapLayer *const layer,
- const MapLayerTypeT &layerType,
- MapHeights *const heights,
- int &restrict x, int &restrict y,
- const int w, const int h)
-{
- if (childNode == nullptr)
- return false;
-
- if (!XmlHaveChildContent(childNode))
- return true;
-
- const char *const xmlChars = XmlChildContent(childNode);
- const char *const data = reinterpret_cast<const char*>(xmlChars);
- if (data == nullptr)
- return false;
-
- std::string csv(data);
- size_t oldPos = 0;
-
- const std::map<int, TileAnimation*> &tileAnimations
- = map->getTileAnimations();
- const bool hasAnimations = !tileAnimations.empty();
-
- if (hasAnimations)
- {
- while (oldPos != std::string::npos)
- {
- const size_t pos = csv.find_first_of(',', oldPos);
- if (pos == std::string::npos)
- return false;
-
- const int gid = atoi(csv.substr(oldPos, pos - oldPos).c_str());
- setTile(map, layer, layerType, heights, x, y, gid);
- TileAnimationMapCIter it = tileAnimations.find(gid);
- if (it != tileAnimations.end())
- {
- TileAnimation *const ani = it->second;
- if (ani != nullptr)
- ani->addAffectedTile(layer, x + y * w);
- }
-
- x++;
- if (x == w)
- {
- x = 0; y++;
-
- // When we're done, don't crash on too much data
- if (y == h)
- return false;
- }
- oldPos = pos + 1;
- }
- }
- else
- {
- while (oldPos != std::string::npos)
- {
- const size_t pos = csv.find_first_of(',', oldPos);
- if (pos == std::string::npos)
- return false;
-
- const int gid = atoi(csv.substr(oldPos, pos - oldPos).c_str());
- setTile(map, layer, layerType, heights, x, y, gid);
-
- x++;
- if (x == w)
- {
- x = 0; y++;
-
- // When we're done, don't crash on too much data
- if (y == h)
- return false;
- }
- oldPos = pos + 1;
- }
- }
- return true;
-}
-
-void MapReader::readLayer(XmlNodeConstPtr node, Map *const map)
-{
- if (node == nullptr)
- return;
-
- // Layers are not necessarily the same size as the map
- const int w = XML::getProperty(node, "width", map->getWidth());
- const int h = XML::getProperty(node, "height", map->getHeight());
- const int offsetX = XML::getProperty(node, "x", 0);
- const int offsetY = XML::getProperty(node, "y", 0);
- std::string name = XML::getProperty(node, "name", "");
- name = toLower(name);
-
- const bool isFringeLayer = (name.substr(0, 6) == "fringe");
- const bool isCollisionLayer = (name.substr(0, 9) == "collision");
- const bool isHeightLayer = (name.substr(0, 7) == "heights");
- const bool isActionsLayer = (name.substr(0, 7) == "actions");
- int mask = 1;
- int tileCondition = -1;
- int conditionLayer = 0;
-
- MapLayerTypeT layerType = MapLayerType::TILES;
- if (isCollisionLayer)
- layerType = MapLayerType::COLLISION;
- else if (isHeightLayer)
- layerType = MapLayerType::HEIGHTS;
- else if (isActionsLayer)
- layerType = MapLayerType::ACTIONS;
-
- map->indexTilesets();
-
- MapLayer *layer = nullptr;
- MapHeights *heights = nullptr;
-
- logger->log("- Loading layer \"%s\"", name.c_str());
- int x = 0;
- int y = 0;
-
- // Load the tile data
- for_each_xml_child_node(childNode, node)
- {
- if (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")
- {
- if (value == "1")
- return;
- }
- else if (pname == "Version")
- {
- if (value > CHECK_VERSION)
- return;
- }
- else if (pname == "NotVersion")
- {
- if (value <= CHECK_VERSION)
- return;
- }
- else if (pname == "Mask")
- {
- mask = atoi(value.c_str());
- }
- else if (pname == "TileCondition")
- {
- tileCondition = atoi(value.c_str());
- }
- else if (pname == "ConditionLayer")
- {
- conditionLayer = atoi(value.c_str());
- }
- else if (pname == "SideView")
- {
- if (value != "down")
- return;
- }
- }
- }
-
- if (!xmlNameEqual(childNode, "data"))
- continue;
-
- // Disable for future usage "TileCondition" attribute
- // if already set ConditionLayer to non zero
- if (conditionLayer != 0)
- tileCondition = -1;
-
- switch (layerType)
- {
- case MapLayerType::TILES:
- {
- layer = new MapLayer(name,
- offsetX, offsetY,
- w, h,
- isFringeLayer,
- mask,
- tileCondition);
- map->addLayer(layer);
- break;
- }
- case MapLayerType::HEIGHTS:
- {
- heights = new MapHeights(w, h);
- map->addHeights(heights);
- break;
- }
- default:
- case MapLayerType::ACTIONS:
- case MapLayerType::COLLISION:
- break;
- }
-
- const std::string encoding =
- XML::getProperty(childNode, "encoding", "");
- const std::string compression =
- XML::getProperty(childNode, "compression", "");
-
- if (encoding == "base64")
- {
- if (readBase64Layer(childNode, map, layer, layerType,
- heights, compression, x, y, w, h))
- {
- continue;
- }
- else
- {
- return;
- }
- }
- else if (encoding == "csv")
- {
- if (readCsvLayer(childNode, map, layer, layerType,
- heights, x, y, w, h))
- {
- continue;
- }
- else
- {
- return;
- }
- }
- else
- {
- const std::map<int, TileAnimation*> &tileAnimations
- = map->getTileAnimations();
- const bool hasAnimations = !tileAnimations.empty();
-
- // Read plain XML map file
- for_each_xml_child_node(childNode2, childNode)
- {
- if (!xmlNameEqual(childNode2, "tile"))
- continue;
-
- const int gid = XML::getProperty(childNode2, "gid", -1);
- setTile(map, layer, layerType, heights, x, y, gid);
- if (hasAnimations)
- {
- TileAnimationMapCIter it = tileAnimations.find(gid);
- if (it != tileAnimations.end())
- {
- TileAnimation *const ani = it->second;
- if (ani != nullptr)
- ani->addAffectedTile(layer, x + y * w);
- }
- }
-
- x++;
- if (x == w)
- {
- x = 0; y++;
- if (y >= h)
- break;
- }
- }
- }
-
- if (y < h)
- std::cerr << "TOO SMALL!\n";
- if (x != 0)
- std::cerr << "TOO SMALL!\n";
-
- // There can be only one data element
- break;
- }
-}
-
-Tileset *MapReader::readTileset(XmlNodePtr node,
- const std::string &path,
- Map *const map)
-{
- BLOCK_START("MapReader::readTileset")
- if (node == nullptr)
- {
- BLOCK_END("MapReader::readTileset")
- return nullptr;
- }
-
- const int firstGid = XML::getProperty(node, "firstgid", 0);
- const int margin = XML::getProperty(node, "margin", 0);
- const int spacing = XML::getProperty(node, "spacing", 0);
- XML::Document* doc = nullptr;
- Tileset *set = nullptr;
- std::string pathDir(path);
- std::map<std::string, std::string> props;
-
- if (XmlHasProp(node, "source"))
- {
- std::string filename = XML::getProperty(node, "source", "");
- filename = resolveRelativePath(path, filename);
-
- doc = new XML::Document(filename, UseVirtFs_true, SkipError_false);
- node = doc->rootNode();
- if (node == nullptr)
- {
- delete doc;
- BLOCK_END("MapReader::readTileset")
- return nullptr;
- }
-
- // Reset path to be realtive to the tsx file
- pathDir = filename.substr(0, filename.rfind('/') + 1);
- }
-
- const int tw = XML::getProperty(node, "tilewidth", map->getTileWidth());
- const int th = XML::getProperty(node, "tileheight", map->getTileHeight());
-
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "image"))
- {
- // ignore second other <image> tags in tileset
- if (set != nullptr)
- continue;
-
- const std::string source = XML::getProperty(
- childNode, "source", "");
-
- if (!source.empty())
- {
- Image *const tilebmp = Loader::getImage(
- resolveRelativePath(pathDir, source));
-
- if (tilebmp != nullptr)
- {
- set = new Tileset(tilebmp,
- tw, th,
- firstGid,
- margin,
- spacing);
- tilebmp->decRef();
-#ifdef USE_OPENGL
- if (tilebmp->getType() == ImageType::Image &&
- map->haveAtlas() == true &&
- graphicsManager.getUseAtlases())
- {
- reportAlways("Error: image '%s' not present in atlas",
- source.c_str());
- }
-#endif // USE_OPENGL
- }
- else
- {
- reportAlways("Error: Failed to load tileset (%s)",
- source.c_str());
- }
- }
- }
- else if (xmlNameEqual(childNode, "properties"))
- {
- for_each_xml_child_node(propertyNode, childNode)
- {
- if (!xmlNameEqual(propertyNode, "property"))
- continue;
- const std::string name = XML::getProperty(
- propertyNode, "name", "");
- if (!name.empty())
- props[name] = XML::getProperty(propertyNode, "value", "");
- }
- }
- else if (xmlNameEqual(childNode, "tile"))
- {
- bool haveAnimation(false);
-
- for_each_xml_child_node(tileNode, childNode)
- {
- const bool isProps = xmlNameEqual(tileNode, "properties");
- const bool isAnim = xmlNameEqual(tileNode, "animation");
- if (!isProps && !isAnim)
- continue;
-
- const int tileGID = firstGid + XML::getProperty(
- childNode, "id", 0);
-
- Animation *ani = new Animation("from map");
-
- if (isProps)
- {
- // read tile properties to a map for simpler handling
- StringIntMap tileProperties;
- for_each_xml_child_node(propertyNode, tileNode)
- {
- if (!xmlNameEqual(propertyNode, "property"))
- continue;
-
- haveAnimation = true;
- const std::string name = XML::getProperty(
- propertyNode, "name", "");
- const int value = XML::getProperty(
- propertyNode, "value", 0);
- if (!name.empty())
- {
- tileProperties[name] = value;
- logger->log("Tile Prop of %d \"%s\" = \"%d\"",
- tileGID, name.c_str(), value);
- }
- }
-
- // create animation
- if (set == nullptr ||
- !config.getBoolValue("playMapAnimations"))
- {
- delete ani;
- continue;
- }
-
- for (int i = 0; ; i++)
- {
- const std::string iStr(toString(i));
- StringIntMapCIter iFrame
- = tileProperties.find("animation-frame" + iStr);
- StringIntMapCIter iDelay
- = tileProperties.find("animation-delay" + iStr);
- // possible need add random attribute?
- if (iFrame != tileProperties.end()
- && iDelay != tileProperties.end())
- {
- ani->addFrame(set->get(iFrame->second),
- iDelay->second, 0, 0, 100);
- }
- else
- {
- break;
- }
- }
- }
- else if (isAnim && !haveAnimation)
- {
- for_each_xml_child_node(frameNode, tileNode)
- {
- if (!xmlNameEqual(frameNode, "frame"))
- continue;
-
- const int tileId = XML::getProperty(
- frameNode, "tileid", 0);
- const int duration = XML::getProperty(
- frameNode, "duration", 0) / 10;
-
- if (set != nullptr)
- {
- ani->addFrame(set->get(tileId),
- duration,
- 0, 0, 100);
- }
- }
- }
-
- if (ani->getLength() > 0)
- map->addAnimation(tileGID, new TileAnimation(ani));
- else
- delete2(ani)
- }
- }
- }
-
- delete doc;
-
- if (set != nullptr)
- set->setProperties(props);
- BLOCK_END("MapReader::readTileset")
- return set;
-}
-
-Map *MapReader::createEmptyMap(const std::string &restrict filename,
- const std::string &restrict realFilename)
-{
- logger->log1("Creating empty map");
- Map *const map = new Map("empty map",
- 300, 300,
- mapTileSize, mapTileSize);
- map->setProperty("_filename", realFilename);
- map->setProperty("_realfilename", filename);
- updateMusic(map);
- map->setCustom(true);
- MapLayer *layer = new MapLayer("nolayer",
- 0, 0,
- 300, 300,
- false,
- 1,
- -1);
- map->addLayer(layer);
- layer = new MapLayer("nolayer",
- 0, 0,
- 300, 300,
- true,
- 1,
- -1);
- map->addLayer(layer);
- map->updateDrawLayersList();
- map->updateConditionLayers();
- map->preCacheLayers();
-
- return map;
-}
-
-void MapReader::updateMusic(Map *const map)
-{
- std::string name = map->getProperty("shortName");
- const size_t p = name.rfind('.');
- if (p != std::string::npos)
- name = name.substr(0, p);
- name.append(".ogg");
- if (VirtFs::exists(pathJoin(paths.getStringValue("music"), name)))
- map->setProperty("music", name);
-}
-
-#ifdef USE_OPENGL
-void MapReader::loadEmptyAtlas()
-{
- if (!graphicsManager.getUseAtlases())
- return;
-
- const MapInfo *const info = MapDB::getAtlas(
- paths.getStringValue("emptyAtlasName"));
- if (info != nullptr)
- {
- mEmptyAtlas = Loader::getEmptyAtlas(
- info->atlas,
- *info->files);
- delete info;
- }
-}
-
-void MapReader::unloadEmptyAtlas()
-{
- if (mEmptyAtlas != nullptr)
- mEmptyAtlas->decRef();
-}
-#endif // USE_OPENGL
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
deleted file mode 100644
index 2fd1e067c..000000000
--- a/src/resources/mapreader.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MAPREADER_H
-#define RESOURCES_MAPREADER_H
-
-#include "enums/resources/map/maplayertype.h"
-
-#include "utils/xml.h"
-
-class Map;
-class MapHeights;
-class MapLayer;
-class Properties;
-class Resource;
-class Tileset;
-
-/**
- * Reader for XML map files (*.tmx)
- */
-class MapReader final
-{
- public:
- A_DELETE_COPY(MapReader)
-
- /**
- * Read an XML map from a file.
- */
- static Map *readMap(const std::string &restrict filename,
- const std::string &restrict realFilename)
- A_WARN_UNUSED;
-
- /**
- * Read an XML map from a parsed XML tree. The path is used to find the
- * location of referenced tileset images.
- */
- static Map *readMap(XmlNodePtrConst node,
- const std::string &path) A_WARN_UNUSED;
-
- static Map *createEmptyMap(const std::string &restrict filename,
- const std::string &restrict realFilename)
- A_WARN_UNUSED;
-
- /**
- * Reads a map layer and adds it to the given map.
- */
- static void readLayer(XmlNodeConstPtr node,
- Map *const map) A_NONNULL(2);
-
-#ifdef USE_OPENGL
- static void loadEmptyAtlas();
- static void unloadEmptyAtlas();
-#endif // USE_OPENGL
-
- private:
- /**
- * Reads the properties element.
- *
- * @param node The <code>properties</code> element.
- * @param props The Properties instance to which the properties will
- * be assigned.
- */
- static void readProperties(XmlNodeConstPtrConst node,
- Properties *const props) A_NONNULL(2);
-
- static bool readBase64Layer(XmlNodeConstPtrConst childNode,
- Map *const map,
- MapLayer *const layer,
- const MapLayerTypeT &layerType,
- MapHeights *const heights,
- const std::string &compression,
- int &restrict x, int &restrict y,
- const int w, const int h) A_NONNULL(2);
-
- static bool readCsvLayer(XmlNodeConstPtrConst childNode,
- Map *const map,
- MapLayer *const layer,
- const MapLayerTypeT &layerType,
- MapHeights *const heights,
- int &restrict x, int &restrict y,
- const int w, const int h) A_NONNULL(2);
-
- /**
- * Reads a tile set.
- */
- static Tileset *readTileset(XmlNodePtr node,
- const std::string &path,
- Map *const map) A_WARN_UNUSED A_NONNULL(3);
-
- static void updateMusic(Map *const map) A_NONNULL(1);
-
- static void addLayerToList(const std::string &fileName,
- const SkipError skipError);
-
- static void loadLayers(const std::string &path);
-
- static void unloadTempLayers();
-
-#ifdef USE_OPENGL
- static Resource *mEmptyAtlas;
-#endif // USE_OPENGL
-};
-
-#endif // RESOURCES_MAPREADER_H
diff --git a/src/resources/memorycounter.cpp b/src/resources/memorycounter.cpp
deleted file mode 100644
index 7ed23879f..000000000
--- a/src/resources/memorycounter.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/memorycounter.h"
-
-#include "resources/memorymanager.h"
-
-#include "debug.h"
-
-MemoryCounter::MemoryCounter()
-{
-}
-
-int MemoryCounter::calcMemoryLocal() const
-{
- return 0;
-}
-
-int MemoryCounter::calcMemory(const int level) const
-{
- const int sumLocal = calcMemoryLocal();
- const int sumChilds = calcMemoryChilds(level);
- memoryManager.printMemory(getCounterName(),
- level,
- sumLocal,
- sumChilds);
- return sumLocal + sumChilds;
-}
-
-int MemoryCounter::calcMemoryChilds(const int level A_UNUSED) const
-{
- return 0;
-}
diff --git a/src/resources/memorycounter.h b/src/resources/memorycounter.h
deleted file mode 100644
index ea79ee607..000000000
--- a/src/resources/memorycounter.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MEMORYCOUNTER_H
-#define RESOURCES_MEMORYCOUNTER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class MemoryCounter notfinal
-{
- public:
- MemoryCounter();
-
- A_DEFAULT_COPY(MemoryCounter)
-
-PRAGMACLANG(GCC diagnostic push)
-PRAGMACLANG(GCC diagnostic ignored "-Wdeprecated")
- virtual ~MemoryCounter()
- { }
-PRAGMACLANG(GCC diagnostic pop)
-
- int calcMemory(const int level) const;
-
- virtual int calcMemoryLocal() const;
-
- virtual int calcMemoryChilds(const int level) const;
-
- virtual std::string getCounterName() const
- { return "unknown"; }
-};
-
-#endif // RESOURCES_MEMORYCOUNTER_H
diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp
deleted file mode 100644
index 466a14d61..000000000
--- a/src/resources/memorymanager.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/memorymanager.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_video.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-MemoryManager memoryManager;
-
-MemoryManager::MemoryManager()
-{
-}
-
-
-int MemoryManager::getSurfaceSize(const SDL_Surface *const surface)
-{
- if (surface == nullptr)
- return 0;
- return CAST_S32(sizeof(SDL_Surface)) +
- CAST_S32(sizeof(SDL_PixelFormat)) +
- // aproximation for sizeof(SDL_BlitMap)
- 28 +
- // pixels
- surface->w * surface->h * 4 +
- // private_hdata aproximation
- 10;
-}
-
-void MemoryManager::printMemory(const std::string &name,
- const int level,
- const int localSum,
- const int childsSum)
-{
- std::string str(level, ' ');
- if (childsSum > 0)
- {
- logger->log("%s%s: %d = %d + %d",
- str.c_str(),
- name.c_str(),
- localSum + childsSum,
- localSum,
- childsSum);
- }
- else
- {
- logger->log("%s%s: %d",
- str.c_str(),
- name.c_str(),
- localSum);
- }
-}
-
-void MemoryManager::printAllMemory(ChatTab *const tab A_DYECMD_UNUSED)
-{
- if (logger == nullptr)
- return;
-
-#ifdef DYECMD
- ResourceManager::calcMemory(0);
-#else // DYECMD
-
- int sz = ResourceManager::calcMemory(0);
- if (tab != nullptr)
- {
- // TRANSLATORS: memory usage chat message
- tab->chatLog(strprintf(_("Calculated memory usage: %d"), sz),
- ChatMsgType::BY_SERVER);
- }
-#endif // DYECMD
-}
diff --git a/src/resources/memorymanager.h b/src/resources/memorymanager.h
deleted file mode 100644
index 602b39e2b..000000000
--- a/src/resources/memorymanager.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MEMORYMANAGER_H
-#define MEMORYMANAGER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class ChatTab;
-
-struct SDL_Surface;
-
-class MemoryManager final
-{
- public:
- MemoryManager();
-
- A_DELETE_COPY(MemoryManager)
-
- ~MemoryManager()
- { }
-
- int getSurfaceSize(const SDL_Surface *const surface);
-
- void printMemory(const std::string &name,
- const int level,
- const int localSum,
- const int childsSum);
-
- void printAllMemory(ChatTab *const tab);
-};
-
-extern MemoryManager memoryManager;
-
-#endif // MEMORYMANAGER_H
diff --git a/src/resources/missileinfo.h b/src/resources/missileinfo.h
deleted file mode 100644
index 262a2fb83..000000000
--- a/src/resources/missileinfo.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MISSILEINFO_H
-#define RESOURCES_MISSILEINFO_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct MissileInfo final
-{
- MissileInfo() :
- particle(),
- z(32.0F),
- speed(7.0F),
- dieDistance(8.0F),
- lifeTime(500)
- { }
-
- A_DELETE_COPY(MissileInfo)
-
- std::string particle;
- float z;
- float speed;
- float dieDistance;
- int lifeTime;
-};
-
-#endif // RESOURCES_MISSILEINFO_H
diff --git a/src/resources/mobileopenglscreenshothelper.cpp b/src/resources/mobileopenglscreenshothelper.cpp
deleted file mode 100644
index 3276ea07f..000000000
--- a/src/resources/mobileopenglscreenshothelper.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#if defined(USE_OPENGL) && !defined(ANDROID)
-
-#include "resources/mobileopenglscreenshothelper.h"
-
-#include "configuration.h"
-#include "graphicsmanager.h"
-
-#include "render/graphics.h"
-
-#include "render/opengl/mgl.h"
-#ifdef __native_client__
-#include "render/opengl/naclglfunctions.h"
-#endif // __native_client__
-
-#include "debug.h"
-
-MobileOpenGLScreenshotHelper::MobileOpenGLScreenshotHelper() :
- ScreenshotHelper(),
- mFbo()
-{
-}
-
-MobileOpenGLScreenshotHelper::~MobileOpenGLScreenshotHelper()
-{
-}
-
-void MobileOpenGLScreenshotHelper::prepare()
-{
- if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mainGraphics->mWidth,
- mainGraphics->mHeight,
- &mFbo);
-}
-
-SDL_Surface *MobileOpenGLScreenshotHelper::getScreenshot()
-{
- const int h = mainGraphics->mHeight;
- const int w = mainGraphics->mWidth - (mainGraphics->mWidth % 4);
- GLint pack = 1;
-
- SDL_Surface *const tmpImage = MSDL_CreateRGBSurface(
- SDL_SWSURFACE, w, h, 32,
- 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
-
- if (tmpImage == nullptr)
- return nullptr;
-
- // Grap the pixel buffer and write it to the SDL surface
- mglGetIntegerv(GL_PACK_ALIGNMENT, &pack);
- mglPixelStorei(GL_PACK_ALIGNMENT, 1);
- mglReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->pixels);
-
- const size_t lineSize = 3 * w;
- GLubyte *const buf = new GLubyte[lineSize];
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(
- SDL_SWSURFACE, w, h, 24,
- 0xff0000, 0x00ff00, 0x0000ff, 0x000000);
-
- if (screenshot == nullptr)
- {
- MSDL_FreeSurface(tmpImage);
- delete [] buf;
- return nullptr;
- }
-
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
- SDL_SetSurfaceBlendMode(tmpImage, SDL_BLENDMODE_NONE);
-#else // USE_SDL2
-
- // Make sure the alpha channel is not used, but copied to destination
- SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif // USE_SDL2
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_LockSurface(screenshot);
-
- SDL_BlitSurface(tmpImage, nullptr, screenshot, nullptr);
- MSDL_FreeSurface(tmpImage);
-
- // Flip the screenshot, as OpenGL has 0,0 in bottom left
- const int h2 = h / 2;
- for (int i = 0; i < h2; i++)
- {
- GLubyte *const top = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * i;
- GLubyte *const bot = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * (h - 1 - i);
-
- memcpy(buf, top, lineSize);
- memcpy(top, bot, lineSize);
- memcpy(bot, buf, lineSize);
- }
-
- delete [] buf;
-
- if (config.getBoolValue("usefbo"))
- graphicsManager.deleteFBO(&mFbo);
-
- mglPixelStorei(GL_PACK_ALIGNMENT, pack);
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_UnlockSurface(screenshot);
-
- return screenshot;
-}
-
-#endif // defined(USE_OPENGL) && !defined(ANDROID)
diff --git a/src/resources/mobileopenglscreenshothelper.h b/src/resources/mobileopenglscreenshothelper.h
deleted file mode 100644
index 05aeb4e77..000000000
--- a/src/resources/mobileopenglscreenshothelper.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MOBILEOPENGLSCREENSHOTHELPER_H
-#define RESOURCES_MOBILEOPENGLSCREENSHOTHELPER_H
-
-#if defined(USE_OPENGL) && !defined(ANDROID)
-
-#include "resources/screenshothelper.h"
-
-#include "resources/fboinfo.h"
-
-#include "localconsts.h"
-
-class MobileOpenGLScreenshotHelper final : public ScreenshotHelper
-{
- public:
- MobileOpenGLScreenshotHelper();
-
- A_DELETE_COPY(MobileOpenGLScreenshotHelper)
-
- ~MobileOpenGLScreenshotHelper();
-
- void prepare() override final;
-
- SDL_Surface *getScreenshot() override final;
-
- private:
- FBOInfo mFbo;
-};
-
-#endif // defined(USE_OPENGL) && !defined(ANDROID)
-#endif // RESOURCES_MOBILEOPENGLSCREENSHOTHELPER_H
diff --git a/src/resources/modinfo.cpp b/src/resources/modinfo.cpp
deleted file mode 100644
index 8b456212c..000000000
--- a/src/resources/modinfo.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/modinfo.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-ModInfo::ModInfo() :
- // TRANSLATORS: being info default name
- mName(_("unnamed")),
- mDescription(),
- mHelp(),
- mLocalDir()
-{
-}
diff --git a/src/resources/modinfo.h b/src/resources/modinfo.h
deleted file mode 100644
index beee2e79f..000000000
--- a/src/resources/modinfo.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MODINFO_H
-#define RESOURCES_MODINFO_H
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-class ModInfo final
-{
- public:
- ModInfo();
-
- A_DELETE_COPY(ModInfo)
-
- void setName(const std::string &name) noexcept2
- { mName = name; }
-
- const std::string &getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- void setDescription(const std::string &text) noexcept2
- { mDescription = text; }
-
- const std::string &getDescription() const noexcept2 A_WARN_UNUSED
- { return mDescription; }
-
- void setHelp(const std::string &text) noexcept2
- { mHelp = text; }
-
- const std::string &getHelp() const noexcept2 A_WARN_UNUSED
- { return mHelp; }
-
- void setLocalDir(const std::string &text)
- { mLocalDir = text; }
-
- const std::string &getLocalDir() const noexcept2 A_WARN_UNUSED
- { return mLocalDir; }
-
- private:
- std::string mName;
- std::string mDescription;
- std::string mHelp;
- std::string mLocalDir;
-};
-
-typedef std::map<std::string, ModInfo*> ModInfos;
-typedef ModInfos::iterator ModInfoIterator;
-typedef ModInfos::const_iterator ModInfoCIterator;
-
-#endif // RESOURCES_MODINFO_H
diff --git a/src/resources/mstack.h b/src/resources/mstack.h
deleted file mode 100644
index 9216b94dc..000000000
--- a/src/resources/mstack.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2015-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_MSTACK_H
-#define RESOURCES_MSTACK_H
-
-#include "logger.h"
-
-#include "localconsts.h"
-
-template<typename T>
-struct MStack final
-{
- constexpr2 explicit MStack(const size_t maxSize) :
- mStack(new T[maxSize]),
- mMaxSize(maxSize),
- mPointer(mStack - 1),
- mStartPointer(mStack - 1),
- mEndPointer(mStack + maxSize - 1)
- {
- }
-
- ~MStack()
- {
- delete [] mStack;
- }
-
- A_DELETE_COPY(MStack)
-
- T &push()
- {
- if (mPointer == mEndPointer)
- {
- logger->log("error: max stack size reached");
- return *mPointer;
- }
- return *(++mPointer);
- }
-
- T &getPop()
- {
- return *(mPointer--);
- }
-
- const T &getPopConst()
- {
- return *(mPointer--);
- }
-
- void pop()
- {
- mPointer --;
- }
-
- T &top() const
- {
- return *mPointer;
- }
-
- const T &topConst() const
- {
- return *mPointer;
- }
-
- void clear()
- {
- mPointer = mStack - 1;
- }
-
- bool empty() const
- {
- return mPointer == mStartPointer;
- }
-
- T *mStack;
-
- size_t mMaxSize;
- T *mPointer;
- const T *const mStartPointer;
- const T *const mEndPointer;
-};
-
-#endif // RESOURCES_MSTACK_H
diff --git a/src/resources/notificationinfo.h b/src/resources/notificationinfo.h
deleted file mode 100644
index 1e698615f..000000000
--- a/src/resources/notificationinfo.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_NOTIFICATIONINFO_H
-#define RESOURCES_NOTIFICATIONINFO_H
-
-#include "localconsts.h"
-
-#include "enums/resources/notifyflags.h"
-
-struct NotificationInfo final
-{
-#ifdef ADVGCC
- NotificationInfo(const char *const sound0,
- const char *const text0,
- const NotifyFlagsT flags0) :
- sound(sound0),
- text(text0),
- flags(flags0)
- { }
-
- A_DELETE_COPY(NotificationInfo)
-#endif // ADVGCC
-
- const char *sound;
- const char *text;
- const NotifyFlagsT flags;
-};
-
-#endif // RESOURCES_NOTIFICATIONINFO_H
diff --git a/src/resources/notifications.h b/src/resources/notifications.h
deleted file mode 100644
index 037cf25a2..000000000
--- a/src/resources/notifications.h
+++ /dev/null
@@ -1,914 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_NOTIFICATIONS_H
-#define RESOURCES_NOTIFICATIONS_H
-
-#include "enums/resources/notifytypes.h"
-
-#include "resources/notificationinfo.h"
-
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-namespace NotifyManager
-{
- static const NotificationInfo notifications[NotifyTypes::TYPE_END] =
- {
- {"",
- "", NotifyFlags::EMPTY},
- {"buy done",
- // TRANSLATORS: notification message
- N_("Thanks for buying."),
- NotifyFlags::EMPTY},
- {"buy fail",
- // TRANSLATORS: notification message
- N_("Unable to buy."),
- NotifyFlags::EMPTY},
- {"buy fail no money",
- // TRANSLATORS: notification message
- N_("Unable to buy. You don't have enough money."),
- NotifyFlags::EMPTY},
- {"buy fail overweight",
- // TRANSLATORS: notification message
- N_("Unable to buy. It is too heavy."),
- NotifyFlags::EMPTY},
- {"buy fail too many items",
- // TRANSLATORS: notification message
- N_("Unable to buy. You have too many items."),
- NotifyFlags::EMPTY},
- {"sell empty",
- // TRANSLATORS: notification message
- N_("Nothing to sell."),
- NotifyFlags::EMPTY},
- {"sell done",
- // TRANSLATORS: notification message
- N_("Thanks for selling."),
- NotifyFlags::EMPTY},
- {"sell fail",
- // TRANSLATORS: notification message
- N_("Unable to sell."),
- NotifyFlags::EMPTY},
- {"sell trade fail",
- // TRANSLATORS: notification message
- N_("Unable to sell while trading."),
- NotifyFlags::EMPTY},
- {"sell unsellable fail",
- // TRANSLATORS: notification message
- N_("Unable to sell unsellable item."),
- NotifyFlags::EMPTY},
- {"online users",
- // TRANSLATORS: notification message
- N_("Online users: %d"),
- NotifyFlags::INT},
- {"guild created",
- // TRANSLATORS: notification message
- N_("Guild created."),
- NotifyFlags::EMPTY},
- {"guild already",
- // TRANSLATORS: notification message
- N_("You are already in a guild."),
- NotifyFlags::EMPTY},
- {"guild create fail",
- // TRANSLATORS: notification message
- N_("Emperium check failed."),
- NotifyFlags::EMPTY},
- {"guild error",
- // TRANSLATORS: notification message
- N_("Unknown server response."),
- NotifyFlags::EMPTY},
- {"guild left",
- // TRANSLATORS: notification message
- N_("You have left the guild."),
- NotifyFlags::EMPTY},
- {"guild invite fail",
- // TRANSLATORS: notification message
- N_("Could not invite user to guild."),
- NotifyFlags::GUILD},
- {"guild invite rejected",
- // TRANSLATORS: notification message
- N_("User rejected guild invite."),
- NotifyFlags::GUILD},
- {"guild invite joined",
- // TRANSLATORS: notification message
- N_("User is now part of your guild."),
- NotifyFlags::GUILD},
- {"guild invite full",
- // TRANSLATORS: notification message
- N_("Your guild is full."),
- NotifyFlags::GUILD},
- {"guild invite error",
- // TRANSLATORS: notification message
- N_("Unknown guild invite response."),
- NotifyFlags::GUILD},
- {"guild user left",
- // TRANSLATORS: notification message
- N_("%s has left your guild."),
- NotifyFlags::GUILD_STRING},
- {"guild kicked",
- // TRANSLATORS: notification message
- N_("You were kicked from guild."),
- NotifyFlags::EMPTY},
- {"guild user kicked",
- // TRANSLATORS: notification message
- N_("%s has been kicked from your guild."),
- NotifyFlags::GUILD_STRING},
- {"use failed",
- // TRANSLATORS: notification message
- N_("Failed to use item."),
- NotifyFlags::EMPTY},
- {"equip failed",
- // TRANSLATORS: notification message
- N_("Unable to equip."),
- NotifyFlags::EMPTY},
- {"equip failed level",
- // TRANSLATORS: notification message
- N_("Unable to equip because you have wrong level."),
- NotifyFlags::EMPTY},
- {"unequip failed",
- // TRANSLATORS: notification message
- N_("Unable to unequip."),
- NotifyFlags::EMPTY},
- {"party create failed",
- // TRANSLATORS: notification message
- N_("Couldn't create party."),
- NotifyFlags::EMPTY},
- {"party created",
- // TRANSLATORS: notification message
- N_("Party successfully created."),
- NotifyFlags::EMPTY},
- {"party left",
- // TRANSLATORS: notification message
- N_("You have left the party."),
- NotifyFlags::EMPTY},
- {"party left deny",
- // TRANSLATORS: notification message
- N_("You can't leave party on this map."),
- NotifyFlags::EMPTY},
- {"party kicked",
- // TRANSLATORS: notification message
- N_("You were kicked from party."),
- NotifyFlags::EMPTY},
- {"party kick deny",
- // TRANSLATORS: notification message
- N_("You can't be kicked from party on this map."),
- NotifyFlags::EMPTY},
- {"party user joined",
- // TRANSLATORS: notification message
- N_("%s has joined your party."),
- NotifyFlags::PARTY_STRING},
- {"party invite already member",
- // TRANSLATORS: notification message
- N_("%s is already a member of a party."),
- NotifyFlags::PARTY_STRING},
- {"party invite refused",
- // TRANSLATORS: notification message
- N_("%s refused your invitation."),
- NotifyFlags::PARTY_STRING},
- {"party invite done",
- // TRANSLATORS: notification message
- N_("%s is now a member of your party."),
- NotifyFlags::PARTY_STRING},
- {"party invite full",
- // TRANSLATORS: notification message
- N_("%s can't join your party because party is full."),
- NotifyFlags::PARTY_STRING},
- {"party invite error",
- // TRANSLATORS: notification message
- N_("QQQ Unknown invite response for %s."),
- NotifyFlags::PARTY_STRING},
- {"party exp sharing on",
- // TRANSLATORS: notification message
- N_("Experience sharing enabled."),
- NotifyFlags::PARTY},
- {"party exp sharing off",
- // TRANSLATORS: notification message
- N_("Experience sharing disabled."),
- NotifyFlags::PARTY},
- {"party exp sharing error",
- // TRANSLATORS: notification message
- N_("Experience sharing not possible."),
- NotifyFlags::PARTY},
- {"party item sharing on",
- // TRANSLATORS: notification message
- N_("Item sharing enabled."),
- NotifyFlags::PARTY},
- {"party item sharing off",
- // TRANSLATORS: notification message
- N_("Item sharing disabled."),
- NotifyFlags::PARTY},
- {"party item sharing error",
- // TRANSLATORS: notification message
- N_("Item sharing not possible."),
- NotifyFlags::PARTY},
- {"party user left",
- // TRANSLATORS: notification message
- N_("%s has left your party."),
- NotifyFlags::PARTY_STRING},
- {"party user left deny",
- // TRANSLATORS: notification message
- N_("%s can't be kicked from party on this map."),
- NotifyFlags::PARTY_STRING},
- {"party user kicked",
- // TRANSLATORS: notification message
- N_("%s has kicked from your party."),
- NotifyFlags::PARTY_STRING},
- {"party user kick deny",
- // TRANSLATORS: notification message
- N_("%s can't be kicked from party on this map."),
- NotifyFlags::PARTY_STRING},
- {"party unknown user msg",
- // TRANSLATORS: notification message
- N_("An unknown member tried to say: %s"),
- NotifyFlags::PARTY_STRING},
- {"party user not in party",
- // TRANSLATORS: notification message
- N_("%s is not in your party!"),
- NotifyFlags::PARTY_STRING},
- {"money get",
- // TRANSLATORS: notification message
- N_("You picked up %s."),
- NotifyFlags::STRING},
- {"money spend",
- // TRANSLATORS: notification message
- N_("You spent %s."),
- NotifyFlags::STRING},
- {"skill raise error",
- // TRANSLATORS: notification message
- N_("Cannot raise skill!"),
- NotifyFlags::EMPTY},
- {"arrow equip needed",
- // TRANSLATORS: notification message
- N_("Equip ammunition first."),
- NotifyFlags::EMPTY},
- {"trade fail far away",
- // TRANSLATORS: notification message
- N_("Trading with %s isn't possible. Trade partner is "
- "too far away."),
- NotifyFlags::STRING},
- {"trade fail chat not exists",
- // TRANSLATORS: notification message
- N_("Trading with %s isn't possible. Character doesn't exist."),
- NotifyFlags::STRING},
- {"trade cancelled error",
- // TRANSLATORS: notification message
- N_("Trade cancelled due to an unknown reason."),
- NotifyFlags::EMPTY},
- {"trade cancelled user",
- // TRANSLATORS: notification message
- N_("Trade with %s cancelled."),
- NotifyFlags::STRING},
- {"trade cancelled busy",
- // TRANSLATORS: notification message
- N_("Trade with %s cancelled, because player is busy"),
- NotifyFlags::STRING},
- {"trade error unknown",
- // TRANSLATORS: notification message
- N_("Unhandled trade cancel packet with %s"),
- NotifyFlags::STRING},
- {"trade add partner over weighted",
- // TRANSLATORS: notification message
- N_("Failed adding item. Trade partner is over weighted."),
- NotifyFlags::EMPTY},
- {"trade add partned has no free slots",
- // TRANSLATORS: notification message
- N_("Failed adding item. Trade partner has no free slot."),
- NotifyFlags::EMPTY},
- {"trade add untradable item",
- // TRANSLATORS: notification message
- N_("Failed adding item. You can't trade this item."),
- NotifyFlags::EMPTY},
- {"trade add error",
- // TRANSLATORS: notification message
- N_("Failed adding item for unknown reason."),
- NotifyFlags::EMPTY},
- {"trade cancelled",
- // TRANSLATORS: notification message
- N_("Trade canceled."),
- NotifyFlags::EMPTY},
- {"trade complete",
- // TRANSLATORS: notification message
- N_("Trade completed."),
- NotifyFlags::EMPTY},
- {"kick fail",
- // TRANSLATORS: notification message
- N_("Kick failed!"),
- NotifyFlags::EMPTY},
- {"kick succeed",
- // TRANSLATORS: notification message
- N_("Kick succeeded!"),
- NotifyFlags::EMPTY},
- {"mvp player",
- // TRANSLATORS: notification message
- N_("MVP player: %s"),
- NotifyFlags::STRING},
- {"whispers ignored",
- // TRANSLATORS: notification message
- N_("All whispers ignored."),
- NotifyFlags::EMPTY},
- {"whispers ignore failed",
- // TRANSLATORS: notification message
- N_("All whispers ignore failed."),
- NotifyFlags::EMPTY},
- {"whispers unignored",
- // TRANSLATORS: notification message
- N_("All whispers unignored."),
- NotifyFlags::EMPTY},
- {"whispers unignore failed",
- // TRANSLATORS: notification message
- N_("All whispers unignore failed."),
- NotifyFlags::EMPTY},
- {"skill fail message",
- "%s",
- NotifyFlags::STRING},
- {"pvp off gvg off",
- // TRANSLATORS: notification message
- N_("pvp off, gvg off"),
- NotifyFlags::SPEECH},
- {"pvp on",
- // TRANSLATORS: notification message
- N_("pvp on"),
- NotifyFlags::SPEECH},
- {"gvg on",
- // TRANSLATORS: notification message
- N_("gvg on"),
- NotifyFlags::SPEECH},
- {"pvp on gvg on",
- // TRANSLATORS: notification message
- N_("pvp on, gvg on"),
- NotifyFlags::SPEECH},
- {"unknown pvp",
- // TRANSLATORS: notification message
- N_("unknown pvp"),
- NotifyFlags::SPEECH},
- {"party user char from account in party",
- // TRANSLATORS: notification message
- N_("Char from account %s is already in your party!"),
- NotifyFlags::PARTY_STRING},
- {"party user blocked invite",
- // TRANSLATORS: notification message
- N_("%s blocked invite!"),
- NotifyFlags::PARTY_STRING},
- {"party user not online",
- // TRANSLATORS: notification message
- N_("Char is not online!"),
- NotifyFlags::PARTY_STRING},
- {"pet catch failed",
- // TRANSLATORS: notification message
- N_("Pet catch failed."),
- NotifyFlags::EMPTY},
- {"pet catch success",
- // TRANSLATORS: notification message
- N_("Pet caught."),
- NotifyFlags::EMPTY},
- {"pet catch unknown error",
- // TRANSLATORS: notification message
- N_("Pet catch unknown error: %d."),
- NotifyFlags::INT},
- {"mercenary expired",
- // TRANSLATORS: notification message
- N_("Your mercenary duty hour is over."),
- NotifyFlags::EMPTY},
- {"mercenary killed",
- // TRANSLATORS: notification message
- N_("Your mercenary was killed."),
- NotifyFlags::EMPTY},
- {"mercenary fired",
- // TRANSLATORS: notification message
- N_("Your mercenary was fired."),
- NotifyFlags::EMPTY},
- {"mercenary run",
- // TRANSLATORS: notification message
- N_("Your mercenary run away."),
- NotifyFlags::EMPTY},
- {"mercenary unknown",
- // TRANSLATORS: notification message
- N_("Mercenary unknown state."),
- NotifyFlags::EMPTY},
- {"homunculus feed ok",
- // TRANSLATORS: notification message
- N_("You feed your homunculus."),
- NotifyFlags::EMPTY},
- {"homunculus feed failed",
- // TRANSLATORS: notification message
- N_("You can't feed homunculus, because you don't have any %s."),
- NotifyFlags::STRING},
- {"card insert failed",
- // TRANSLATORS: notification message
- N_("Card insert failed."),
- NotifyFlags::EMPTY},
- {"card insert success",
- // TRANSLATORS: notification message
- N_("Card inserted."),
- NotifyFlags::EMPTY},
- {"bank deposit failed",
- // TRANSLATORS: notification message
- N_("Deposit failed. You probably don't have this "
- "amount of money with you right now."),
- NotifyFlags::EMPTY},
- {"bank withdraw failed",
- // TRANSLATORS: notification message
- N_("Withdraw failed. You probably don't have this "
- "amount of money in the bank right now."),
- NotifyFlags::EMPTY},
- {"buying store create failed",
- // TRANSLATORS: notification message
- N_("Buying store create failed."),
- NotifyFlags::EMPTY},
- {"buying store create failed weight",
- // TRANSLATORS: notification message
- N_("Buying store create failed. Too many weight."),
- NotifyFlags::INT},
- {"buying store create empty",
- // TRANSLATORS: notification message
- N_("Buying store create failed. No items in store."),
- NotifyFlags::EMPTY},
- {"buying store buy failed money limit",
- // TRANSLATORS: notification message
- N_("All items within the buy limit were purchased."),
- NotifyFlags::EMPTY},
- {"buying store buy failed empty",
- // TRANSLATORS: notification message
- N_("All items were purchased."),
- NotifyFlags::EMPTY},
- {"buying store buy failed",
- // TRANSLATORS: notification message
- N_("Buying item failed."),
- NotifyFlags::EMPTY},
- {"buying store sell failed deal",
- // TRANSLATORS: notification message
- N_("The deal has failed."),
- NotifyFlags::EMPTY},
- {"buying store sell failed amount",
- // TRANSLATORS: notification message
- N_("The trade failed, because the entered amount of item is "
- "higher, than the buyer is willing to buy."),
- NotifyFlags::EMPTY},
- {"buying store sell failed balance",
- // TRANSLATORS: notification message
- N_("The trade failed, because the buyer is "
- "lacking required balance."),
- NotifyFlags::EMPTY},
- {"buying store sell failed",
- // TRANSLATORS: notification message
- N_("Selling item failed."),
- NotifyFlags::EMPTY},
-
- {"search store failed",
- // TRANSLATORS: notification message
- N_("Items searching failed."),
- NotifyFlags::EMPTY},
- {"search store failed no stores",
- // TRANSLATORS: notification message
- N_("No matching stores were found."),
- NotifyFlags::EMPTY},
- {"search store failed many results",
- // TRANSLATORS: notification message
- N_("There are too many results. Please enter more "
- "detailed search term."),
- NotifyFlags::EMPTY},
- {"search store failed cant search anymore",
- // TRANSLATORS: notification message
- N_("You cannot search anymore."),
- NotifyFlags::EMPTY},
- {"search store failed cant search yet",
- // TRANSLATORS: notification message
- N_("You cannot search yet."),
- NotifyFlags::EMPTY},
- {"search store failed no information",
- // TRANSLATORS: notification message
- N_("No store information available."),
- NotifyFlags::EMPTY},
- {"pet feed ok",
- // TRANSLATORS: notification message
- N_("Pet feeding success."),
- NotifyFlags::EMPTY},
- {"pet feed error",
- // TRANSLATORS: notification message
- N_("Pet feeding error."),
- NotifyFlags::EMPTY},
- {"manner changed",
- // TRANSLATORS: notification message
- N_("A manner point has been successfully aligned."),
- NotifyFlags::EMPTY},
- {"manner positive points",
- // TRANSLATORS: notification message
- N_("You got positive manner points from %s."),
- NotifyFlags::STRING},
- {"manner negative points",
- // TRANSLATORS: notification message
- N_("You got negative manner points from %s."),
- NotifyFlags::STRING},
- {"chat room limit exceed",
- // TRANSLATORS: notification message
- N_("Chat room limit exceeded"),
- NotifyFlags::EMPTY},
- {"chat room already exists",
- // TRANSLATORS: notification message
- N_("Chat room already exists"),
- NotifyFlags::EMPTY},
- {"chat room joined",
- // TRANSLATORS: notification message
- N_("%s joined room."),
- NotifyFlags::STRING},
- {"chat room leave",
- // TRANSLATORS: notification message
- N_("%s left room."),
- NotifyFlags::STRING},
- {"chat room kick",
- // TRANSLATORS: notification message
- N_("%s kicked from room."),
- NotifyFlags::STRING},
- {"chat room role owner",
- // TRANSLATORS: notification message
- N_("%s role changed to room owner."),
- NotifyFlags::STRING},
- {"chat room error full",
- // TRANSLATORS: notification message
- N_("Room join failed. Room full."),
- NotifyFlags::EMPTY},
- {"chat room error password",
- // TRANSLATORS: notification message
- N_("Room join failed. Wrong password."),
- NotifyFlags::EMPTY},
- {"chat room error kicked",
- // TRANSLATORS: notification message
- N_("Room join failed. Kicked from room."),
- NotifyFlags::EMPTY},
- {"chat room error zeny",
- // TRANSLATORS: notification message
- N_("Room join failed. Not enough money."),
- NotifyFlags::EMPTY},
- {"chat room error low level",
- // TRANSLATORS: notification message
- N_("Room join failed. Too low level."),
- NotifyFlags::EMPTY},
- {"chat room error high level",
- // TRANSLATORS: notification message
- N_("Room join failed. Too high level."),
- NotifyFlags::EMPTY},
- {"chat room error race",
- // TRANSLATORS: notification message
- N_("Room join failed. Wrong race."),
- NotifyFlags::EMPTY},
- {"chat room error race",
- // TRANSLATORS: notification message
- N_("Left %d seconds until you can use item."),
- NotifyFlags::INT},
- {"mail send ok",
- // TRANSLATORS: notification message
- N_("Message successfully sent."),
- NotifyFlags::EMPTY},
- {"mail send error",
- // TRANSLATORS: notification message
- N_("Message send failed."),
- NotifyFlags::EMPTY},
- {"mail attach item error",
- // TRANSLATORS: notification message
- N_("Item attach failed."),
- NotifyFlags::EMPTY},
- {"mail attach money error",
- // TRANSLATORS: notification message
- N_("Money attach failed."),
- NotifyFlags::EMPTY},
- {"mail return error",
- // TRANSLATORS: notification message
- N_("Message return failed."),
- NotifyFlags::EMPTY},
- {"mail return ok",
- // TRANSLATORS: notification message
- N_("Message return success."),
- NotifyFlags::EMPTY},
- {"mail delete error",
- // TRANSLATORS: notification message
- N_("Message deletion failed."),
- NotifyFlags::EMPTY},
- {"mail delete ok",
- // TRANSLATORS: notification message
- N_("Message successfully deleted."),
- NotifyFlags::EMPTY},
- {"mail get attach ok",
- // TRANSLATORS: notification message
- N_("You got attach successfully."),
- NotifyFlags::EMPTY},
- {"mail get attach error",
- // TRANSLATORS: notification message
- N_("Error on getting attach successfully."),
- NotifyFlags::EMPTY},
- {"mail get attach too many items",
- // TRANSLATORS: notification message
- N_("Can't get attach. Too many items."),
- NotifyFlags::EMPTY},
- {"new mail",
- "%s",
- NotifyFlags::STRING},
- {"mail type battle field",
- // TRANSLATORS: notification message
- N_("You enter battle field."),
- NotifyFlags::EMPTY},
- {"rental time left",
- "%s",
- NotifyFlags::STRING},
- {"rental time expired",
- // TRANSLATORS: notification message
- N_("Rental time for %s expired"),
- NotifyFlags::STRING},
- {"refine success",
- // TRANSLATORS: notification message
- N_("Refine success for item %s."),
- NotifyFlags::STRING},
- {"refine failure",
- // TRANSLATORS: notification message
- N_("Refine failure for item %s."),
- NotifyFlags::STRING},
- {"refine downgrade",
- // TRANSLATORS: notification message
- N_("Refine failure. Item %s downgraded."),
- NotifyFlags::STRING},
- {"refine unknown",
- // TRANSLATORS: notification message
- N_("Refine unknown for item %s."),
- NotifyFlags::STRING},
- {"cart add weight error",
- // TRANSLATORS: notification message
- N_("You can't add item to card because weight too high."),
- NotifyFlags::EMPTY},
- {"cart add count error",
- // TRANSLATORS: notification message
- N_("You can't add item to card because too many items."),
- NotifyFlags::EMPTY},
- {"bound item",
- // TRANSLATORS: notification message
- N_("Item %s bound to you."),
- NotifyFlags::STRING},
- {"skill end all negative status",
- // TRANSLATORS: notification message
- N_("End all negative status."),
- NotifyFlags::EMPTY},
- {"skill immunity to all status",
- // TRANSLATORS: notification message
- N_("Immunity to all status."),
- NotifyFlags::EMPTY},
- {"skill max hp",
- // TRANSLATORS: notification message
- N_("Max hp +100%."),
- NotifyFlags::EMPTY},
- {"skill max sp",
- // TRANSLATORS: notification message
- N_("Max sp +100%."),
- NotifyFlags::EMPTY},
- {"skill all stats +20",
- // TRANSLATORS: notification message
- N_("All stats +20."),
- NotifyFlags::EMPTY},
- {"skill enchant weapon with holy element",
- // TRANSLATORS: notification message
- N_("Enchant weapon with holy element."),
- NotifyFlags::EMPTY},
- {"skill enchant armor with holy element",
- // TRANSLATORS: notification message
- N_("Enchant armor with holy element."),
- NotifyFlags::EMPTY},
- {"skill def +25%",
- // TRANSLATORS: notification message
- N_("Def +25%."),
- NotifyFlags::EMPTY},
- {"skill atk +100%",
- // TRANSLATORS: notification message
- N_("Atk +100%."),
- NotifyFlags::EMPTY},
- {"skill flee +50",
- // TRANSLATORS: notification message
- N_("Flee +50."),
- NotifyFlags::EMPTY},
- {"skill full strip failed",
- // TRANSLATORS: notification message
- N_("Full strip failed because of coating."),
- NotifyFlags::EMPTY},
- {"skill message unknown",
- // TRANSLATORS: notification message
- N_("Unknown skill message."),
- NotifyFlags::EMPTY},
- {"ignore player success",
- // TRANSLATORS: notification message
- N_("Player successfully ignored."),
- NotifyFlags::EMPTY},
- {"ignore player failure",
- // TRANSLATORS: notification message
- N_("Player ignore failed."),
- NotifyFlags::EMPTY},
- {"ignore player too many",
- // TRANSLATORS: notification message
- N_("Player ignore failed. Because too many ignores."),
- NotifyFlags::EMPTY},
- {"ignore player unknown",
- // TRANSLATORS: notification message
- N_("Unknown player ignore failure."),
- NotifyFlags::EMPTY},
- {"unignore player success",
- // TRANSLATORS: notification message
- N_("Player successfully unignored."),
- NotifyFlags::EMPTY},
- {"unignore player failure",
- // TRANSLATORS: notification message
- N_("Player unignore failed."),
- NotifyFlags::EMPTY},
- {"unignore player unknown",
- // TRANSLATORS: notification message
- N_("Unknown player unignore failure."),
- NotifyFlags::EMPTY},
- {"ignore unknown type",
- // TRANSLATORS: notification message
- N_("Unknown ignore type."),
- NotifyFlags::EMPTY},
- {"pet catch process",
- // TRANSLATORS: notification message
- N_("Pet catch started."),
- NotifyFlags::EMPTY},
- {"delete item normal",
- "",
- NotifyFlags::STRING},
- {"delete item skill use",
- "",
- NotifyFlags::STRING},
- {"delete item fail refine",
- "",
- NotifyFlags::STRING},
- {"delete item material change",
- "",
- NotifyFlags::STRING},
- {"delete item to storage",
- "",
- NotifyFlags::STRING},
- {"delete item to cart",
- "",
- NotifyFlags::STRING},
- {"delete item sold",
- "",
- NotifyFlags::STRING},
- {"delete item analysis",
- "",
- NotifyFlags::STRING},
- {"delete item unknown",
- "",
- NotifyFlags::STRING},
- {"delete item dropped",
- "",
- NotifyFlags::STRING},
- {"being remove died",
- // TRANSLATORS: notification message
- N_("Player %s died."),
- NotifyFlags::STRING},
- {"being remove logged out",
- // TRANSLATORS: notification message
- N_("Player %s logged out."),
- NotifyFlags::STRING},
- {"being remove warped",
- // TRANSLATORS: notification message
- N_("Player %s warped."),
- NotifyFlags::STRING},
- {"being remove trick dead",
- // TRANSLATORS: notification message
- N_("Player %s trick dead."),
- NotifyFlags::STRING},
- {"being remove unknown",
- // TRANSLATORS: notification message
- N_("Player %s unknown remove."),
- NotifyFlags::STRING},
- {"player divorced",
- // TRANSLATORS: notification message
- N_("You and %s are now divorced."),
- NotifyFlags::STRING},
- {"partner called",
- // TRANSLATORS: notification message
- N_("You were called by your partner."),
- NotifyFlags::EMPTY},
- {"partner calling",
- // TRANSLATORS: notification message
- N_("You are calling your partner, %s."),
- NotifyFlags::STRING},
- {"adopt child error have baby",
- // TRANSLATORS: notification message
- N_("Child adoption failed. You already have a baby."),
- NotifyFlags::EMPTY},
- {"adopt child error level",
- // TRANSLATORS: notification message
- N_("Child adoption failed. Your level is too low."),
- NotifyFlags::EMPTY},
- {"adopt child error baby married",
- // TRANSLATORS: notification message
- N_("Child adoption failed. This player is already "
- "married and can't be a baby."),
- NotifyFlags::EMPTY},
- {"skill memo saved",
- // TRANSLATORS: notification message
- N_("Saved location for warp skill."),
- NotifyFlags::EMPTY},
- {"skill memo error level",
- // TRANSLATORS: notification message
- N_("Error saving location. Not enough skill level."),
- NotifyFlags::EMPTY},
- {"skill memo error skill",
- // TRANSLATORS: notification message
- N_("Error saving location. You do not have warp skill."),
- NotifyFlags::EMPTY},
- {"buy trade fail",
- // TRANSLATORS: notification message
- N_("Unable to buy while trading."),
- NotifyFlags::EMPTY},
- {"vending sold item",
- ("%s"),
- NotifyFlags::STRING},
- {"buy fail npc not found",
- // TRANSLATORS: notification message
- N_("Unable to buy. Npc not found."),
- NotifyFlags::EMPTY},
- {"buy fail system error",
- // TRANSLATORS: notification message
- N_("Unable to buy. Shop system error."),
- NotifyFlags::EMPTY},
- {"buy fail wrong item",
- // TRANSLATORS: notification message
- N_("Unable to buy. Wrong items selected."),
- NotifyFlags::EMPTY},
- {"mail name validation error",
- // TRANSLATORS: notification message
- N_("Mail destination name %s is wrong."),
- NotifyFlags::STRING},
- {"mail attach item weight error",
- // TRANSLATORS: notification message
- N_("Item attach failed. Weight too big."),
- NotifyFlags::EMPTY},
- {"mail attach item fatal error",
- // TRANSLATORS: notification message
- N_("Item attach failed. Fatal error."),
- NotifyFlags::EMPTY},
- {"mail attach item no space",
- // TRANSLATORS: notification message
- N_("Item attach failed. No more space."),
- NotifyFlags::EMPTY},
- {"mail attach item non tradeable",
- // TRANSLATORS: notification message
- N_("Item attach failed. Item on tradeable."),
- NotifyFlags::EMPTY},
- {"mail attach item unknown error",
- // TRANSLATORS: notification message
- N_("Item attach failed. Unknown error."),
- NotifyFlags::EMPTY},
- {"mail remove item error",
- // TRANSLATORS: notification message
- N_("Item %s remove failed."),
- NotifyFlags::STRING},
- {"mail send fatal error",
- // TRANSLATORS: notification message
- N_("Mail send failed. Fatal error."),
- NotifyFlags::EMPTY},
- {"mail send count error",
- // TRANSLATORS: notification message
- N_("Mail send failed. Too many mails sent."),
- NotifyFlags::EMPTY},
- {"mail send item error",
- // TRANSLATORS: notification message
- N_("Mail send failed. Wrong attach found."),
- NotifyFlags::EMPTY},
- {"mail send receiver error",
- // TRANSLATORS: notification message
- N_("Mail send failed. Receiver name wrong or not checked."),
- NotifyFlags::EMPTY},
- {"mail get attach full error",
- // TRANSLATORS: notification message
- N_("Error on getting attach. No space or weight too high."),
- NotifyFlags::EMPTY},
- {"mail get money ok",
- // TRANSLATORS: notification message
- N_("You got money from mail."),
- NotifyFlags::EMPTY},
- {"mail get money error",
- // TRANSLATORS: notification message
- N_("Error on getting money attach."),
- NotifyFlags::EMPTY},
- {"mail get money limit error",
- // TRANSLATORS: notification message
- N_("Error on getting money attach. Too many money."),
- NotifyFlags::EMPTY},
- };
-} // namespace NotifyManager
-#endif // RESOURCES_NOTIFICATIONS_H
diff --git a/src/resources/npcbuttoninfo.h b/src/resources/npcbuttoninfo.h
deleted file mode 100644
index 6d0b92d77..000000000
--- a/src/resources/npcbuttoninfo.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_NPCBUTTONINFO_H
-#define RESOURCES_NPCBUTTONINFO_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct NpcButtonInfo final
-{
- NpcButtonInfo() :
- name(),
- value(),
- image(),
- x(0),
- y(0),
- imageWidth(16),
- imageHeight(16)
- {
- }
-
- A_DELETE_COPY(NpcButtonInfo)
-
- std::string name;
- std::string value;
- std::string image;
- int x;
- int y;
- int imageWidth;
- int imageHeight;
-};
-
-#endif // RESOURCES_NPCBUTTONINFO_H
diff --git a/src/resources/npcdialoginfo.h b/src/resources/npcdialoginfo.h
deleted file mode 100644
index 9d0ae85b8..000000000
--- a/src/resources/npcdialoginfo.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_NPCDIALOGINFO_H
-#define RESOURCES_NPCDIALOGINFO_H
-
-#include "resources/npcdialogmenuinfo.h"
-#include "resources/npcinventoryinfo.h"
-
-#include "localconsts.h"
-
-struct NpcDialogInfo final
-{
- NpcDialogInfo() :
- menu(),
- inventory(),
- name(),
- hideText(false)
- {
- }
-
- A_DELETE_COPY(NpcDialogInfo)
-
- NpcDialogMenuInfo menu;
- NpcInventoryInfo inventory;
- std::string name;
- bool hideText;
-};
-
-#endif // RESOURCES_NPCDIALOGINFO_H
diff --git a/src/resources/npcdialogmenuinfo.h b/src/resources/npcdialogmenuinfo.h
deleted file mode 100644
index ba25c51d0..000000000
--- a/src/resources/npcdialogmenuinfo.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_NPCDIALOGMENUINFO_H
-#define RESOURCES_NPCDIALOGMENUINFO_H
-
-#include "resources/npcbuttoninfo.h"
-#include "resources/npcimageinfo.h"
-#include "resources/npctextinfo.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-struct NpcDialogMenuInfo final
-{
- NpcDialogMenuInfo() :
- buttons(),
- images(),
- texts()
- {
- }
-
- A_DELETE_COPY(NpcDialogMenuInfo)
-
- STD_VECTOR<NpcButtonInfo*> buttons;
- STD_VECTOR<NpcImageInfo*> images;
- STD_VECTOR<NpcTextInfo*> texts;
-};
-
-#endif // RESOURCES_NPCDIALOGMENUINFO_H
diff --git a/src/resources/npcimageinfo.h b/src/resources/npcimageinfo.h
deleted file mode 100644
index d2cb27874..000000000
--- a/src/resources/npcimageinfo.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_NPCIMAGEINFO_H
-#define RESOURCES_NPCIMAGEINFO_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct NpcImageInfo final
-{
- NpcImageInfo() :
- name(),
- x(0),
- y(0)
- {
- }
-
- A_DELETE_COPY(NpcImageInfo)
-
- std::string name;
- int x;
- int y;
-};
-
-#endif // RESOURCES_NPCIMAGEINFO_H
diff --git a/src/resources/npcinventoryinfo.h b/src/resources/npcinventoryinfo.h
deleted file mode 100644
index 93061abb5..000000000
--- a/src/resources/npcinventoryinfo.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_NPCINVENTORYINFO_H
-#define RESOURCES_NPCINVENTORYINFO_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct NpcInventoryInfo final
-{
- NpcInventoryInfo() :
- cell(),
- columns(100000)
- {
- }
-
- A_DELETE_COPY(NpcInventoryInfo)
-
- std::string cell;
- int columns;
-};
-
-#endif // RESOURCES_NPCINVENTORYINFO_H
diff --git a/src/resources/npctextinfo.h b/src/resources/npctextinfo.h
deleted file mode 100644
index 8312d80e0..000000000
--- a/src/resources/npctextinfo.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_NPCTEXTINFO_H
-#define RESOURCES_NPCTEXTINFO_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct NpcTextInfo final
-{
- NpcTextInfo() :
- text(),
- x(0),
- y(0),
- width(32),
- height(32)
- {
- }
-
- A_DELETE_COPY(NpcTextInfo)
-
- std::string text;
- int x;
- int y;
- int width;
- int height;
-};
-
-#endif // RESOURCES_NPCTEXTINFO_H
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
deleted file mode 100644
index 21d56e500..000000000
--- a/src/resources/openglimagehelper.cpp
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/openglimagehelper.h"
-
-#ifdef USE_OPENGL
-
-#include "graphicsmanager.h"
-
-#include "render/mobileopengl2graphics.h"
-#include "render/mobileopenglgraphics.h"
-#include "render/modernopenglgraphics.h"
-#ifdef __native_client__
-#include "render/opengl/naclglfunctions.h"
-#endif // __native_client__
-#include "render/normalopenglgraphics.h"
-#include "render/safeopenglgraphics.h"
-
-#include "render/opengl/mgl.h"
-#include "render/opengl/mglcheck.h"
-
-#include "resources/dye/dye.h"
-#include "resources/dye/dyepalette.h"
-
-#include "resources/image/image.h"
-
-#include "utils/checkutils.h"
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-int OpenGLImageHelper::mTextureType = 0;
-int OpenGLImageHelper::mInternalTextureType = GL_RGBA8;
-int OpenGLImageHelper::mTextureSize = 0;
-bool OpenGLImageHelper::mBlur = true;
-bool OpenGLImageHelper::mUseTextureSampler = false;
-
-OpenGLImageHelper::~OpenGLImageHelper()
-{
- glDeleteTextures(static_cast<GLsizei>(texturesSize - mFreeTextureIndex),
- &mTextures[mFreeTextureIndex]);
-}
-
-Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
-{
- SDL_Surface *const tmpImage = loadPng(rw);
- if (tmpImage == nullptr)
- {
- reportAlways("Error, image load failed: %s", SDL_GetError());
- return nullptr;
- }
-
- SDL_Surface *const surf = convertTo32Bit(tmpImage);
- MSDL_FreeSurface(tmpImage);
- if (surf == nullptr)
- return nullptr;
-
- uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
- const int type = dye.getType();
-
- switch (type)
- {
- case 1:
- {
- const DyePalette *const pal = dye.getSPalete();
- if (pal != nullptr)
- DYEPALETTEP(pal, SOGLColor)(pixels, surf->w * surf->h);
- break;
- }
- case 2:
- {
- const DyePalette *const pal = dye.getAPalete();
- if (pal != nullptr)
- DYEPALETTEP(pal, AOGLColor)(pixels, surf->w * surf->h);
- break;
- }
- case 0:
- default:
- {
- dye.normalOGLDye(pixels, surf->w * surf->h);
- break;
- }
- }
-
- Image *const image = loadSurface(surf);
- MSDL_FreeSurface(surf);
- return image;
-}
-
-Image *OpenGLImageHelper::loadSurface(SDL_Surface *const tmpImage)
-{
- return glLoad(tmpImage);
-}
-
-Image *OpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- const float alpha)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
- Image *const img = glLoad(tmpImage, width, height);
- if (img != nullptr)
- img->setAlpha(alpha);
- return img;
-}
-
-int OpenGLImageHelper::powerOfTwo(const int input)
-{
- int value = 1;
- while (value < input && value < mTextureSize)
- value <<= 1;
- return value >= mTextureSize ? mTextureSize : value;
-}
-
-SDL_Surface *OpenGLImageHelper::convertSurfaceNormalize(SDL_Surface *tmpImage,
- int width, int height)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
- int realWidth = powerOfTwo(width);
- int realHeight = powerOfTwo(height);
-
- if (realWidth < width || realHeight < height)
- {
- reportAlways("Warning: image too large, cropping to %dx%d texture!",
- tmpImage->w, tmpImage->h);
- }
-
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else // USE_SDL2
-
- // Make sure the alpha channel is not used, but copied to destination
- SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif // USE_SDL2
-
- // Determine 32-bit masks based on byte order
- uint32_t rmask, gmask, bmask, amask;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (tmpImage->format->BitsPerPixel != 32
- || realWidth != width || realHeight != height
- || rmask != tmpImage->format->Rmask
- || gmask != tmpImage->format->Gmask
- || amask != tmpImage->format->Amask)
- {
- SDL_Surface *oldImage = tmpImage;
-#ifdef USE_SDL2
- SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif // USE_SDL2
-
- tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
- 32, rmask, gmask, bmask, amask);
-
- if (tmpImage == nullptr)
- {
- reportAlways("Error, image convert failed: out of memory");
- return nullptr;
- }
- SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
- }
- return tmpImage;
-}
-
-SDL_Surface *OpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
- int width, int height)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else // USE_SDL2
-
- // Make sure the alpha channel is not used, but copied to destination
- SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif // USE_SDL2
-
- // Determine 32-bit masks based on byte order
- uint32_t rmask, gmask, bmask, amask;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (tmpImage->format->BitsPerPixel != 32
- || rmask != tmpImage->format->Rmask
- || gmask != tmpImage->format->Gmask
- || amask != tmpImage->format->Amask)
- {
- SDL_Surface *oldImage = tmpImage;
-#ifdef USE_SDL2
- SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif // USE_SDL2
-
- tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
- 32, rmask, gmask, bmask, amask);
-
- if (tmpImage == nullptr)
- {
- reportAlways("Error, image convert failed: out of memory");
- return nullptr;
- }
- SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
- }
- return tmpImage;
-}
-
-void OpenGLImageHelper::bindTexture(const GLuint texture)
-{
- switch (mUseOpenGL)
- {
-#ifdef ANDROID
- case RENDER_NORMAL_OPENGL:
- case RENDER_SAFE_OPENGL:
- case RENDER_MODERN_OPENGL:
- case RENDER_GLES2_OPENGL:
- break;
- case RENDER_GLES_OPENGL:
- MobileOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
-#elif defined(__native_client__)
- case RENDER_NORMAL_OPENGL:
- case RENDER_MODERN_OPENGL:
- case RENDER_GLES_OPENGL:
- break;
- case RENDER_SAFE_OPENGL:
- SafeOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_GLES2_OPENGL:
- MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
- break;
-#else // ANDROID
-
- case RENDER_NORMAL_OPENGL:
- NormalOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_MODERN_OPENGL:
- ModernOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_SAFE_OPENGL:
- SafeOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_GLES_OPENGL:
- MobileOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_GLES2_OPENGL:
- MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
- break;
-#endif // ANDROID
-
- case RENDER_SOFTWARE:
- case RENDER_SDL2_DEFAULT:
- case RENDER_NULL:
- case RENDER_LAST:
- default:
- reportAlways("Unknown OpenGL backend: %d", mUseOpenGL);
- break;
- }
-}
-
-Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
- int width, int height)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
- BLOCK_START("OpenGLImageHelper::glLoad")
- // Flush current error flag.
- graphicsManager.getLastError();
-
- if (width == 0)
- width = tmpImage->w;
- if (height == 0)
- height = tmpImage->h;
-
- SDL_Surface *oldImage = tmpImage;
- tmpImage = convertSurfaceNormalize(tmpImage, width, height);
- if (tmpImage == nullptr)
- return nullptr;
-
- const int realWidth = tmpImage->w;
- const int realHeight = tmpImage->h;
-
- const GLuint texture = getNewTexture();
- bindTexture(texture);
-
- if (SDL_MUSTLOCK(tmpImage))
- SDL_LockSurface(tmpImage);
-
- if (mUseOpenGL != RENDER_MODERN_OPENGL &&
- mUseOpenGL != RENDER_GLES_OPENGL &&
- mUseOpenGL != RENDER_GLES2_OPENGL)
- {
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
-
- if (!mUseTextureSampler)
- {
- if (mBlur)
- {
- mglTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-
- mglTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
- else
- {
- mglTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-
- mglTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
- }
-#if !defined(ANDROID) && !defined(__native_client__)
- mglTexParameteri(mTextureType, GL_TEXTURE_MAX_LEVEL, 0);
-#endif // !defined(ANDROID) && !defined(__native_client__)
-
- mglTexImage2D(mTextureType, 0, mInternalTextureType,
- tmpImage->w, tmpImage->h,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->pixels);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-
-#ifdef DEBUG_OPENGL
-/*
- disabled for now, because debugger can't show it
- if (isGLNotNull(mglLabelObject))
- {
- const char *const text = "image text";
- mglLabelObject(GL_TEXTURE, texture, strlen(text), text);
- }
-*/
-#endif // DEBUG_OPENGL
-
-/*
- GLint compressed;
- glGetTexLevelParameteriv(mTextureType, 0,
- GL_TEXTURE_COMPRESSED_ARB, &compressed);
- if (compressed)
- logger->log("image compressed");
- else
- logger->log("image not compressed");
-*/
-
-#ifdef DEBUG_OPENGL_LEAKS
- textures_count ++;
-#endif // DEBUG_OPENGL_LEAKS
-
- if (SDL_MUSTLOCK(tmpImage))
- SDL_UnlockSurface(tmpImage);
-
- if (oldImage != tmpImage)
- MSDL_FreeSurface(tmpImage);
-
- GLenum error = graphicsManager.getLastError();
- if (error != 0u)
- {
- std::string errmsg = GraphicsManager::errorToString(error);
- reportAlways("Error: Image GL import failed: %s (%u)",
- errmsg.c_str(), error);
-// return nullptr;
- }
-
- BLOCK_END("OpenGLImageHelper::glLoad")
- return new Image(texture, width, height, realWidth, realHeight);
-}
-
-void OpenGLImageHelper::initTextureSampler(const GLint id)
-{
- if (mBlur)
- {
- mglSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- mglSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
- else
- {
- mglSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- mglSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- }
-}
-
-SDL_Surface *OpenGLImageHelper::create32BitSurface(int width,
- int height) const
-{
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
- const int amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
- const int amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- width = powerOfTwo(width);
- height = powerOfTwo(height);
-
- return MSDL_CreateRGBSurface(SDL_SWSURFACE,
- width, height, 32, rmask, gmask, bmask, amask);
-}
-
-GLuint OpenGLImageHelper::getNewTexture()
-{
- GLuint texture = mTextures[mFreeTextureIndex];
- mFreeTextureIndex ++;
- if (mFreeTextureIndex == texturesSize)
- {
- mFreeTextureIndex = 0;
- postInit();
- }
- return texture;
-}
-
-void OpenGLImageHelper::postInit()
-{
- mglGenTextures(texturesSize, &mTextures[mFreeTextureIndex]);
-}
-
-void OpenGLImageHelper::invalidate(const GLuint textureId)
-{
- if (isGLNotNull(mglInvalidateTexImage))
- {
- logger->log("invalidate: %u", textureId);
- mglInvalidateTexImage(textureId, 0);
- }
-}
-
-void OpenGLImageHelper::copySurfaceToImage(const Image *const image,
- const int x, const int y,
- SDL_Surface *surface) const
-{
- if (surface == nullptr || image == nullptr)
- return;
-
- SDL_Surface *const oldSurface = surface;
- surface = convertSurface(surface, surface->w, surface->h);
- if (surface == nullptr)
- return;
-
- // +++ probably need combine
- // mglTextureSubImage2D and mglTextureSubImage2DEXT
- if (mglTextureSubImage2D != nullptr)
- {
- mglTextureSubImage2D(image->mGLImage,
- 0,
- x, y,
- surface->w, surface->h,
- GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
- }
- else
- {
- mglTextureSubImage2DEXT(image->mGLImage,
- mTextureType, 0,
- x, y,
- surface->w, surface->h,
- GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
- }
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-
- if (surface != oldSurface)
- MSDL_FreeSurface(surface);
-}
-
-#endif // USE_OPENGL
diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h
deleted file mode 100644
index 24662686d..000000000
--- a/src/resources/openglimagehelper.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_OPENGLIMAGEHELPER_H
-#define RESOURCES_OPENGLIMAGEHELPER_H
-
-#include "localconsts.h"
-
-#ifdef USE_OPENGL
-
-#ifndef GL_TEXTURE_RECTANGLE_ARB
-#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
-#endif // GL_TEXTURE_RECTANGLE_ARB
-
-#include "resources/imagehelper.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#define GL_RGBA8 GL_RGBA8_OES
-#else // ANDROID
-#ifndef USE_SDL2
-#define GL_GLEXT_PROTOTYPES 1
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_opengl.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // ANDROID
-
-class Dye;
-class Image;
-
-/**
- * Defines a class for loading and storing images.
- */
-class OpenGLImageHelper final : public ImageHelper
-{
- friend class CompoundSprite;
- friend class Graphics;
- friend class Image;
-
- public:
- OpenGLImageHelper() :
- mFreeTextureIndex(0U),
- mTextures()
- {
- }
-
- A_DELETE_COPY(OpenGLImageHelper)
-
- ~OpenGLImageHelper();
-
- /**
- * Loads an image from an SDL_RWops structure and recolors it.
- *
- * @param rw The SDL_RWops to load the image from.
- * @param dye The dye used to recolor the image.
- *
- * @return <code>NULL</code> if an error occurred, a valid pointer
- * otherwise.
- */
- Image *load(SDL_RWops *const rw,
- Dye const &dye) override final A_WARN_UNUSED;
-
- /**
- * Loads an image from an SDL surface.
- */
- Image *loadSurface(SDL_Surface *const tmpImage) override final
- A_WARN_UNUSED;
-
- Image *createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- const float alpha)
- override final A_WARN_UNUSED;
-
- // OpenGL only public functions
-
- static int getTextureType() noexcept2 A_WARN_UNUSED
- { return mTextureType; }
-
- static int getInternalTextureType() noexcept2 A_WARN_UNUSED
- { return mInternalTextureType; }
-
- constexpr2 static void setInternalTextureType(const int n) noexcept2
- { mInternalTextureType = n; }
-
- constexpr2 static void setBlur(const bool n) noexcept2
- { mBlur = n; }
-
- static int mTextureType;
-
- static int mInternalTextureType;
-
- static int getTextureSize() noexcept2 A_WARN_UNUSED
- { return mTextureSize; }
-
- static void initTextureSampler(const GLint id);
-
- constexpr2 static void setUseTextureSampler(const bool b) noexcept2
- { mUseTextureSampler = b; }
-
- static void invalidate(const GLuint textureId);
-
- static void bindTexture(const GLuint texture);
-
- SDL_Surface *create32BitSurface(int width,
- int height) const override final;
-
- void postInit() override final;
-
- void copySurfaceToImage(const Image *const image,
- const int x, const int y,
- SDL_Surface *surface) const override final;
-
- protected:
- /**
- * Returns the first power of two equal or bigger than the input.
- */
- static int powerOfTwo(const int input) A_WARN_UNUSED;
-
- static SDL_Surface *convertSurfaceNormalize(SDL_Surface *tmpImage,
- int width, int height);
-
- static SDL_Surface *convertSurface(SDL_Surface *tmpImage,
- int width, int height);
-
- Image *glLoad(SDL_Surface *tmpImage,
- int width = 0, int height = 0) A_WARN_UNUSED;
-
- GLuint getNewTexture();
-
- static const size_t texturesSize = 10;
- size_t mFreeTextureIndex;
- GLuint mTextures[texturesSize];
-
- static int mTextureSize;
- static bool mBlur;
- static bool mUseTextureSampler;
-};
-
-#endif // USE_OPENGL
-#endif // RESOURCES_OPENGLIMAGEHELPER_H
diff --git a/src/resources/openglscreenshothelper.cpp b/src/resources/openglscreenshothelper.cpp
deleted file mode 100644
index ef77832f6..000000000
--- a/src/resources/openglscreenshothelper.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "resources/openglscreenshothelper.h"
-
-#include "configuration.h"
-#include "graphicsmanager.h"
-
-#include "render/graphics.h"
-#include "render/opengl/mgl.h"
-#ifdef __native_client__
-#include "render/opengl/naclglfunctions.h"
-#endif // __native_client__
-
-#include "debug.h"
-
-OpenGLScreenshotHelper::OpenGLScreenshotHelper() :
- ScreenshotHelper(),
- mFbo()
-{
-}
-
-OpenGLScreenshotHelper::~OpenGLScreenshotHelper()
-{
-}
-
-void OpenGLScreenshotHelper::prepare()
-{
- if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mainGraphics->mWidth,
- mainGraphics->mHeight,
- &mFbo);
-}
-
-SDL_Surface *OpenGLScreenshotHelper::getScreenshot()
-{
- const int h = mainGraphics->mHeight;
- const int w = mainGraphics->mWidth - (mainGraphics->mWidth % 4);
- GLint pack = 1;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(
- SDL_SWSURFACE, w, h, 24,
- 0xff0000, 0x00ff00, 0x0000ff, 0x000000);
-
- if (screenshot == nullptr)
- return nullptr;
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_LockSurface(screenshot);
-
- const size_t lineSize = 3 * w;
- GLubyte *const buf = new GLubyte[lineSize];
-
- // Grap the pixel buffer and write it to the SDL surface
- mglGetIntegerv(GL_PACK_ALIGNMENT, &pack);
- mglPixelStorei(GL_PACK_ALIGNMENT, 1);
- mglReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels);
-
- // Flip the screenshot, as OpenGL has 0,0 in bottom left
- const int h2 = h / 2;
- for (int i = 0; i < h2; i++)
- {
- GLubyte *const top = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * i;
- GLubyte *const bot = static_cast<GLubyte*>(
- screenshot->pixels) + lineSize * (h - 1 - i);
-
- memcpy(buf, top, lineSize);
- memcpy(top, bot, lineSize);
- memcpy(bot, buf, lineSize);
- }
-
- delete [] buf;
-
- if (config.getBoolValue("usefbo"))
- graphicsManager.deleteFBO(&mFbo);
-
- mglPixelStorei(GL_PACK_ALIGNMENT, pack);
-
- if (SDL_MUSTLOCK(screenshot))
- SDL_UnlockSurface(screenshot);
-
- return screenshot;
-}
-
-#endif // USE_OPENGL
diff --git a/src/resources/openglscreenshothelper.h b/src/resources/openglscreenshothelper.h
deleted file mode 100644
index d2aa16b4a..000000000
--- a/src/resources/openglscreenshothelper.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_OPENGLSCREENSHOTHELPER_H
-#define RESOURCES_OPENGLSCREENSHOTHELPER_H
-
-#ifdef USE_OPENGL
-
-#include "resources/screenshothelper.h"
-
-#include "resources/fboinfo.h"
-
-#include "localconsts.h"
-
-class OpenGLScreenshotHelper final : public ScreenshotHelper
-{
- public:
- OpenGLScreenshotHelper();
-
- A_DELETE_COPY(OpenGLScreenshotHelper)
-
- ~OpenGLScreenshotHelper();
-
- void prepare() override final;
-
- SDL_Surface *getScreenshot() override final;
-
- private:
- FBOInfo mFbo;
-};
-
-#endif // USE_OPENGL
-#endif // RESOURCES_OPENGLSCREENSHOTHELPER_H
diff --git a/src/resources/questeffect.h b/src/resources/questeffect.h
deleted file mode 100644
index 60ff0ae78..000000000
--- a/src/resources/questeffect.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_QUESTEFFECT_H
-#define RESOURCES_QUESTEFFECT_H
-
-#include "enums/simpletypes/beingtypeid.h"
-
-#include <set>
-#include <string>
-
-#include "localconsts.h"
-
-struct QuestEffect final
-{
- QuestEffect() :
- map(),
- var(0),
- id(BeingTypeId_zero),
- effectId(0),
- values()
- {
- }
-
- A_DELETE_COPY(QuestEffect)
-
- std::string map;
- int var;
- BeingTypeId id;
- int effectId;
- std::set<int> values;
-};
-
-#endif // RESOURCES_QUESTEFFECT_H
diff --git a/src/resources/questitem.h b/src/resources/questitem.h
deleted file mode 100644
index 333cc308b..000000000
--- a/src/resources/questitem.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_QUESTITEM_H
-#define RESOURCES_QUESTITEM_H
-
-#include "resources/questitemtext.h"
-
-#include "utils/vector.h"
-
-#include <set>
-
-#include "localconsts.h"
-
-struct QuestItem final
-{
- QuestItem() :
- var(0),
- name(),
- group(),
- incomplete(),
- complete(),
- texts(),
- completeFlag(-1),
- broken(false)
- {
- }
-
- A_DELETE_COPY(QuestItem)
-
- int var;
- std::string name;
- std::string group;
- std::set<int> incomplete;
- std::set<int> complete;
- STD_VECTOR<QuestItemText> texts;
- int completeFlag;
- bool broken;
-};
-
-#endif // RESOURCES_QUESTITEM_H
diff --git a/src/resources/questitemtext.h b/src/resources/questitemtext.h
deleted file mode 100644
index 6f7b7d1ee..000000000
--- a/src/resources/questitemtext.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_QUESTITEMTEXT_H
-#define RESOURCES_QUESTITEMTEXT_H
-
-#include "enums/resources/questtype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct QuestItemText final
-{
- QuestItemText(const std::string &text0,
- const QuestTypeT type0,
- const std::string &str1,
- const std::string &str2) :
- text(text0),
- type(type0),
- data1(str1),
- data2(str2)
- {
- }
-
- A_DEFAULT_COPY(QuestItemText)
-
- std::string text;
- QuestTypeT type;
- std::string data1;
- std::string data2;
-};
-
-#endif // RESOURCES_QUESTITEMTEXT_H
diff --git a/src/resources/questvar.h b/src/resources/questvar.h
deleted file mode 100644
index 1164d0f58..000000000
--- a/src/resources/questvar.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_QUESTVAR_H
-#define RESOURCES_QUESTVAR_H
-
-#include <map>
-
-#include "localconsts.h"
-
-struct QuestVar final
-{
- QuestVar() :
- var1(0),
- var2(0),
- var3(0),
- time1(0)
- {
- }
-
- QuestVar(const int v1,
- const int v2,
- const int v3,
- const int t) :
- var1(v1),
- var2(v2),
- var3(v3),
- time1(t)
- {
- }
-
- A_DEFAULT_COPY(QuestVar)
-
- int var1;
- int var2;
- int var3;
- int time1;
-};
-
-typedef std::map<int, QuestVar> NpcQuestVarMap;
-typedef NpcQuestVarMap::const_iterator NpcQuestVarMapCIter;
-
-#endif // RESOURCES_QUESTVAR_H
diff --git a/src/resources/rect/doublerect.h b/src/resources/rect/doublerect.h
deleted file mode 100644
index 0d37e9f30..000000000
--- a/src/resources/rect/doublerect.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RECT_DOUBLERECT_H
-#define RESOURCES_RECT_DOUBLERECT_H
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_video.h>
-PRAGMA48(GCC diagnostic pop)
-
-struct DoubleRect final
-{
- A_DEFAULT_COPY(DoubleRect)
-
- SDL_Rect src;
- SDL_Rect dst;
-};
-
-#endif // RESOURCES_RECT_DOUBLERECT_H
diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp
deleted file mode 100644
index 256618e66..000000000
--- a/src/resources/resource.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/resource.h"
-
-#include "logger.h"
-
-#include "utils/cast.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-Resource::~Resource()
-{
-}
-
-void Resource::incRef()
-{
-#ifdef DEBUG_IMAGES
- logger->log("before incRef for: %p", static_cast<void*>(this));
- mRefCount++;
- logger->log("after incRef: %p, %u", static_cast<void*>(this), mRefCount);
-#else // DEBUG_IMAGES
-
- mRefCount++;
-#endif // DEBUG_IMAGES
-}
-
-void Resource::decRef()
-{
-#ifdef DEBUG_IMAGES
- logger->log("before decRef for: %p", static_cast<void*>(this));
-#endif // DEBUG_IMAGES
-
- // Reference may not already have reached zero
- if (mRefCount == 0)
- {
- logger->log("Warning: mRefCount already zero for %s", mIdPath.c_str());
- return;
- }
-
- mRefCount--;
-
-#ifdef DEBUG_IMAGES
- logger->log("after decRef: %p, %u", static_cast<void*>(this), mRefCount);
-#endif // DEBUG_IMAGES
-
- if (mRefCount == 0 && !mNotCount)
- {
- // Warn the manager that this resource is no longer used.
- ResourceManager::release(this);
- }
-}
-
-int Resource::calcMemoryLocal() const
-{
- return CAST_S32(sizeof(Resource)) +
- CAST_S32(mIdPath.size()) +
- CAST_S32(mSource.size());
-}
diff --git a/src/resources/resource.h b/src/resources/resource.h
deleted file mode 100644
index a434606a0..000000000
--- a/src/resources/resource.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RESOURCE_H
-#define RESOURCES_RESOURCE_H
-
-#include "resources/memorycounter.h"
-
-#include "localconsts.h"
-
-/**
- * A generic reference counted resource object.
- */
-class Resource notfinal : public MemoryCounter
-{
- public:
- /**
- * Constructor
- */
- Resource() :
- MemoryCounter(),
- mTimeStamp(0),
- mIdPath(),
- mSource(),
- mRefCount(0),
- mProtected(false),
-#ifdef DEBUG_DUMP_LEAKS
- mNotCount(false),
- mDumped(false)
-#else // DEBUG_DUMP_LEAKS
- mNotCount(false)
-#endif // DEBUG_DUMP_LEAKS
- {
- }
-
- A_DELETE_COPY(Resource)
-
- /**
- * Destructor.
- */
- virtual ~Resource();
-
- /**
- * Increments the internal reference count.
- */
- virtual void incRef();
-
- /**
- * Decrements the reference count and deletes the object
- * if no references are left.
- *
- * @return <code>true</code> if the object was deleted
- * <code>false</code> otherwise.
- */
- virtual void decRef();
-
- int calcMemoryLocal() const override;
-
- std::string getCounterName() const override
- { return mIdPath + "-" + mSource; }
-
- time_t mTimeStamp; /**< Time at which the resource was orphaned. */
-
- std::string mIdPath; /**< Path identifying this resource. */
- std::string mSource;
-
- unsigned int mRefCount; /**< Reference count. */
- bool mProtected;
- bool mNotCount;
-
-#ifdef DEBUG_DUMP_LEAKS
- bool mDumped;
-#endif // DEBUG_DUMP_LEAKS
-};
-
-#endif // RESOURCES_RESOURCE_H
diff --git a/src/resources/resourcefunctiontypes.h b/src/resources/resourcefunctiontypes.h
deleted file mode 100644
index 3efa4cbd2..000000000
--- a/src/resources/resourcefunctiontypes.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RESOURCEFUNCTIONTYPES_H
-#define RESOURCES_RESOURCEFUNCTIONTYPES_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class Resource;
-
-struct SDL_RWops;
-
-namespace ResourceManager
-{
- typedef Resource *(*loader)(SDL_RWops *rw,
- const std::string &name);
- typedef Resource *(&generator)(const void *const data);
-} // namespace ResourceManager
-
-#endif // RESOURCES_RESOURCEFUNCTIONTYPES_H
diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp
deleted file mode 100644
index 98c9baab5..000000000
--- a/src/resources/resourcemanager/resourcemanager.cpp
+++ /dev/null
@@ -1,711 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#ifdef USE_OPENGL
-#include "resources/image/image.h"
-#endif // USE_OPENGL
-
-#include "resources/imageset.h"
-
-#include "resources/memorymanager.h"
-
-#include "resources/sprite/spritedef.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#if !defined(DEBUG_DUMP_LEAKS) && !defined(UNITTESTS)
-#include "resources/resourcetypes.h"
-#endif // defined(DEBUG_DUMP_LEAKS) || defined(UNITTESTS)
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_OPENGL
-#include <SDL_image.h>
-#endif // USE_OPENGL
-PRAGMA48(GCC diagnostic pop)
-
-#include <sstream>
-
-#include <sys/time.h>
-
-#include "debug.h"
-
-namespace ResourceManager
-{
-
-std::set<SDL_Surface*> deletedSurfaces;
-Resources mResources;
-Resources mOrphanedResources;
-std::set<Resource*> mDeletedResources;
-time_t mOldestOrphan = 0;
-bool mDestruction = false;
-
-void deleteResourceManager()
-{
- mDestruction = true;
- mResources.insert(mOrphanedResources.begin(), mOrphanedResources.end());
-
- // Release any remaining spritedefs first because they depend on image sets
- ResourceIterator iter = mResources.begin();
-
-#ifdef DEBUG_LEAKS
-#ifdef UNITTESTS
- bool status(false);
-#endif // UNITTESTS
-
- while (iter != mResources.end())
- {
- if (iter->second)
- {
- if (iter->second->mRefCount)
- {
- logger->log(std::string("ResourceLeak: ").append(
- iter->second->mIdPath).append(" (").append(
- toString(iter->second->mRefCount)).append(")"));
-#ifdef UNITTESTS
- status = true;
-#endif // UNITTESTS
- }
- }
- ++iter;
- }
-
-#ifdef UNITTESTS
- if (status)
- reportAlways("Found leaked resources.");
-#endif // UNITTESTS
-
- iter = mResources.begin();
-#endif // DEBUG_LEAKS
-
- while (iter != mResources.end())
- {
-#ifdef DEBUG_LEAKS
- if (iter->second && iter->second->mRefCount)
- {
- ++iter;
- continue;
- }
-#endif // DEBUG_LEAKS
-
- if (dynamic_cast<SpriteDef*>(iter->second) != nullptr)
- {
- cleanUp(iter->second);
- const ResourceIterator toErase = iter;
- ++iter;
- mResources.erase(toErase);
- }
- else
- {
- ++iter;
- }
- }
-
- // Release any remaining image sets first because they depend on images
- iter = mResources.begin();
- while (iter != mResources.end())
- {
-#ifdef DEBUG_LEAKS
- if (iter->second && iter->second->mRefCount)
- {
- ++iter;
- continue;
- }
-#endif // DEBUG_LEAKS
-
- if (dynamic_cast<ImageSet*>(iter->second) != nullptr)
- {
- cleanUp(iter->second);
- const ResourceIterator toErase = iter;
- ++iter;
- mResources.erase(toErase);
- }
- else
- {
- ++iter;
- }
- }
-
- // Release remaining resources, logging the number of dangling references.
- iter = mResources.begin();
- while (iter != mResources.end())
- {
-#ifdef DEBUG_LEAKS
- if (iter->second && iter->second->mRefCount)
- {
- ++iter;
- continue;
- }
-#endif // DEBUG_LEAKS
-
- if (iter->second != nullptr)
- {
- cleanUp(iter->second);
- const ResourceIterator toErase = iter;
- ++iter;
- mResources.erase(toErase);
- }
- else
- {
- ++iter;
- }
- }
- clearDeleted();
- clearScheduled();
- mDestruction = false;
-}
-
-void cleanUp(Resource *const res)
-{
- if (res == nullptr)
- return;
-
- const unsigned refCount = res->mRefCount;
- if (refCount > 0)
- {
- logger->log("ResourceManager::~ResourceManager() cleaning up %u "
- "reference%s to %s",
- refCount,
- (refCount == 1) ? "" : "s",
- res->mIdPath.c_str());
- }
-
- delete res;
-#ifdef DEBUG_LEAKS
- cleanOrphans(true);
-#endif // DEBUG_LEAKS
-}
-
-void cleanProtected()
-{
- ResourceIterator iter = mResources.begin();
- while (iter != mResources.end())
- {
- Resource *const res = iter->second;
- if (res == nullptr)
- {
- ++ iter;
- continue;
- }
- if (res->mProtected)
- {
- res->mProtected = false;
- res->decRef();
- iter = mResources.begin();
- continue;
- }
-
- ++ iter;
- }
-}
-
-bool cleanOrphans(const bool always)
-{
- timeval tv;
- gettimeofday(&tv, nullptr);
- // Delete orphaned resources after 30 seconds.
- time_t oldest = static_cast<time_t>(tv.tv_sec);
- const time_t threshold = oldest - 30;
-
- if (mOrphanedResources.empty() || (!always && mOldestOrphan >= threshold))
- return false;
-
- bool status(false);
- ResourceIterator iter = mOrphanedResources.begin();
- while (iter != mOrphanedResources.end())
- {
- Resource *const res = iter->second;
- if (res == nullptr)
- {
- ++iter;
- continue;
- }
- const time_t t = res->mTimeStamp;
- if (!always && t >= threshold)
- {
- if (t < oldest)
- oldest = t;
- ++ iter;
- }
- else
- {
- logResource(res);
- const ResourceIterator toErase = iter;
- ++iter;
- mOrphanedResources.erase(toErase);
- delete res; // delete only after removal from list,
- // to avoid issues in recursion
- status = true;
- }
- }
-
- mOldestOrphan = oldest;
- return status;
-}
-
-void logResource(const Resource *const res)
-{
- if (res == nullptr)
- return;
-#ifdef USE_OPENGL
- const Image *const image = dynamic_cast<const Image *>(res);
- if (image != nullptr)
- {
- std::string src = image->mSource;
- const int count = image->mRefCount;
- if (count != 0)
- src.append(" ").append(toString(count));
- logger->log("resource(%s, %u) %s", res->mIdPath.c_str(),
- image->getGLImage(), src.c_str());
- }
- else
- {
- std::string src = res->mSource;
- const int count = res->mRefCount;
- if (count > 0)
- src.append(" ").append(toString(count));
- logger->log("resource(%s) %s", res->mIdPath.c_str(), src.c_str());
- }
-#else // USE_OPENGL
-
- logger->log("resource(%s)", res->mIdPath.c_str());
-#endif // USE_OPENGL
-}
-
-void logResources(const std::string &msg)
-{
- logger->log("start of resources: " + msg);
- logger->log("resources");
- FOR_EACH(ResourceIterator, it, mResources)
- {
- logResource((*it).second);
- }
- logger->log("orphaned resources");
- FOR_EACH(ResourceIterator, it, mOrphanedResources)
- {
- logResource((*it).second);
- }
- logger->log("deleted resources");
- FOR_EACH(std::set<Resource*>::iterator, it, mDeletedResources)
- {
- logResource(*it);
- }
- logger->log("end of resources");
-}
-
-void clearDeleted(const bool full)
-{
- bool status(true);
- logger->log1("clear deleted");
- while (status)
- {
- status = false;
- std::set<Resource*>::iterator resDelIter = mDeletedResources.begin();
- while (resDelIter != mDeletedResources.end())
- {
- if ((*resDelIter)->mRefCount == 0u)
- {
- status = true;
- Resource *res = *resDelIter;
- logResource(res);
- mDeletedResources.erase(resDelIter);
- delete res;
- break;
- }
- ++ resDelIter;
- }
- }
- if (full && !mDeletedResources.empty())
- {
- logger->log1("leaks in deleted");
- std::set<Resource*>::iterator resDelIter = mDeletedResources.begin();
- while (resDelIter != mDeletedResources.end())
- {
- logResource(*resDelIter);
-
- // for debug only
-// delete *resDelIter;
- // for debug only
-
- ++ resDelIter;
- }
- }
-}
-
-bool addResource(const std::string &idPath,
- Resource *const resource)
-{
- if (resource != nullptr)
- {
- resource->incRef();
- resource->mIdPath = idPath;
-#ifdef DEBUG_IMAGES
- logger->log("set name %p, %s", static_cast<void*>(resource),
- resource->mIdPath.c_str());
-#endif // DEBUG_IMAGES
-
- mResources[idPath] = resource;
- return true;
- }
- return false;
-}
-
-Resource *getFromCache(const std::string &filename,
- const int variant)
-{
- std::stringstream ss;
- ss << filename << "[" << variant << "]";
- return getFromCache(ss.str());
-}
-
-bool isInCache(const std::string &idPath)
-{
- const ResourceCIterator &resIter = mResources.find(idPath);
- return (resIter != mResources.end() && (resIter->second != nullptr));
-}
-
-Resource *getTempResource(const std::string &idPath)
-{
- const ResourceCIterator &resIter = mResources.find(idPath);
- if (resIter != mResources.end())
- {
- Resource *const res = resIter->second;
- if (resIter->second != nullptr)
- return res;
- }
- return nullptr;
-}
-
-Resource *getFromCache(const std::string &idPath)
-{
- // Check if the id exists, and return the value if it does.
- ResourceIterator resIter = mResources.find(idPath);
- if (resIter != mResources.end())
- {
- if (resIter->second != nullptr)
- resIter->second->incRef();
- return resIter->second;
- }
-
- resIter = mOrphanedResources.find(idPath);
- if (resIter != mOrphanedResources.end())
- {
- Resource *const res = resIter->second;
- mResources.insert(*resIter);
- mOrphanedResources.erase(resIter);
- if (res != nullptr)
- res->incRef();
- return res;
- }
- return nullptr;
-}
-
-Resource *get(const std::string &idPath,
- generator fun,
- const void *const data)
-{
-#ifndef DISABLE_RESOURCE_CACHING
- Resource *resource = getFromCache(idPath);
- if (resource != nullptr)
- return resource;
- resource = fun(data);
-
- if (resource != nullptr)
- {
- resource->incRef();
- resource->mIdPath = idPath;
-#ifdef DEBUG_IMAGES
- logger->log("set name %p, %s", static_cast<void*>(resource),
- resource->mIdPath.c_str());
-#endif // DEBUG_IMAGES
-
- mResources[idPath] = resource;
- }
- else
- {
- reportAlways("Error loading image: %s", idPath.c_str());
- }
-#else // DISABLE_RESOURCE_CACHING
-
- Resource *resource = fun(data, idPath);
-
- if (resource)
- {
- resource->incRef();
- resource->mIdPath = idPath;
-#ifdef DEBUG_IMAGES
- logger->log("set name %p, %s", static_cast<void*>(resource),
- resource->mIdPath.c_str());
-#endif // DEBUG_IMAGES
- }
- else
- {
- reportAlways("Error loading image: " + idPath);
- }
-#endif // DISABLE_RESOURCE_CACHING
-
- // Returns nullptr if the object could not be created.
- return resource;
-}
-
-void release(Resource *const res)
-{
- if ((res == nullptr) || mDestruction)
- return;
-
-#ifndef DISABLE_RESOURCE_CACHING
- std::set<Resource*>::iterator resDelIter = mDeletedResources.find(res);
- if (resDelIter != mDeletedResources.end())
- {
- // we found zero counted image in deleted list. deleting it and exit.
- mDeletedResources.erase(resDelIter);
- delete res;
- return;
- }
-
- ResourceIterator resIter = mResources.find(res->mIdPath);
-
- if (resIter == mResources.end())
- {
- reportAlways("no resource in cache: %s",
- res->mIdPath.c_str());
- delete res;
- return;
- }
- if (resIter->second != res)
- {
- reportAlways("in cache other image: %s",
- res->mIdPath.c_str());
- delete res;
- return;
- }
-
- timeval tv;
- gettimeofday(&tv, nullptr);
- const time_t timestamp = static_cast<time_t>(tv.tv_sec);
-
- res->mTimeStamp = timestamp;
- if (mOrphanedResources.empty())
- mOldestOrphan = timestamp;
-
- mOrphanedResources.insert(*resIter);
- mResources.erase(resIter);
-#else // DISABLE_RESOURCE_CACHING
-
- delete res;
-#endif // DISABLE_RESOURCE_CACHING
-}
-
-void moveToDeleted(Resource *const res)
-{
- if (res == nullptr)
- return;
-
- bool found(false);
- const int count = res->mRefCount;
- if (count == 1)
- logResource(res);
- res->decRef();
- ResourceIterator resIter = mResources.find(res->mIdPath);
- if (resIter != mResources.end() && resIter->second == res)
- {
- mResources.erase(resIter);
- found = true;
- }
- else
- {
- resIter = mOrphanedResources.find(res->mIdPath);
- if (resIter != mOrphanedResources.end() && resIter->second == res)
- {
- mOrphanedResources.erase(resIter);
- found = true;
- }
- }
- if (found)
- {
- if (count > 1)
- mDeletedResources.insert(res);
- else
- delete res;
- }
-}
-
-void decRefDelete(Resource *const res)
-{
- if (res == nullptr)
- return;
-
- const int count = res->mRefCount;
- if (count == 1)
- {
- logResource(res);
-
- ResourceIterator resIter = mResources.find(res->mIdPath);
- if (resIter != mResources.end() && resIter->second == res)
- {
- mResources.erase(resIter);
- }
- else
- {
- resIter = mOrphanedResources.find(res->mIdPath);
- if (resIter != mOrphanedResources.end() && resIter->second == res)
- mOrphanedResources.erase(resIter);
- }
-
- delete res;
- }
- else
- {
- res->decRef();
- }
-}
-
-void deleteInstance()
-{
-#ifdef DUMP_LEAKED_RESOURCES
- logger->log1("clean orphans start");
- ResourceManager::cleanProtected();
- while (ResourceManager::cleanOrphans(true))
- continue;
- logger->log1("clean orphans end");
- ResourceIterator iter = ResourceManager::mResources.begin();
-
-#ifdef UNITTESTS
- bool status(false);
-#endif // UNITTESTS
-
- while (iter != ResourceManager::mResources.end())
- {
- const Resource *const res = iter->second;
- if (res != nullptr)
- {
- if (res->mRefCount != 0u)
- {
- logger->log(std::string("ResourceLeak: ").append(
- res->mIdPath).append(" (").append(toString(
- res->mRefCount)).append(")"));
-#ifdef UNITTESTS
- status = true;
-#endif // UNITTESTS
- }
- }
- ++iter;
- }
-#ifdef UNITTESTS
- if (status)
- reportAlways("Found leaked resources.");
-#endif // UNITTESTS
-#endif // DUMP_LEAKED_RESOURCES
-
- deleteResourceManager();
-}
-
-void scheduleDelete(SDL_Surface *const surface)
-{
- deletedSurfaces.insert(surface);
-}
-
-void clearScheduled()
-{
- BLOCK_START("ResourceManager::clearScheduled")
- FOR_EACH (std::set<SDL_Surface*>::iterator, i, deletedSurfaces)
- MSDL_FreeSurface(*i);
- deletedSurfaces.clear();
- BLOCK_END("ResourceManager::clearScheduled")
-}
-
-void clearCache()
-{
- cleanProtected();
- while (cleanOrphans(true))
- continue;
-}
-
-int calcMemoryLocal()
-{
- int sz = 24;
- FOR_EACH (std::set<SDL_Surface*>::iterator, it, deletedSurfaces)
- {
- sz += memoryManager.getSurfaceSize(*it);
- }
- return sz;
-}
-
-int calcMemoryChilds(const int level)
-{
- int sz = 0;
- FOR_EACH (ResourceCIterator, it, mResources)
- {
- sz += static_cast<int>((*it).first.capacity());
- sz += (*it).second->calcMemory(level + 1);
- }
- FOR_EACH (ResourceCIterator, it, mOrphanedResources)
- {
- sz += static_cast<int>((*it).first.capacity());
- sz += (*it).second->calcMemory(level + 1);
- }
- FOR_EACH (std::set<Resource*>::const_iterator, it, mDeletedResources)
- {
- sz += (*it)->calcMemory(level + 1);
- }
- return sz;
-}
-
-int calcMemory(const int level)
-{
- const int sumLocal = calcMemoryLocal();
- const int sumChilds = calcMemoryChilds(0);
- memoryManager.printMemory("resource manager",
- level,
- sumLocal,
- sumChilds);
- return sumLocal + sumChilds;
-}
-
-int size() noexcept2
-{
- return CAST_S32(mResources.size());
-}
-
-#if defined(DEBUG_DUMP_LEAKS) || defined(UNITTESTS)
-Resources &getResources()
-{
- return mResources;
-}
-
-Resources &getOrphanedResources()
-{
- return mOrphanedResources;
-}
-
-const std::set<Resource*> &getDeletedResources()
-{
- return mDeletedResources;
-}
-#endif // defined(DEBUG_DUMP_LEAKS) || defined(UNITTESTS)
-
-} // namespace ResourceManager
diff --git a/src/resources/resourcemanager/resourcemanager.h b/src/resources/resourcemanager/resourcemanager.h
deleted file mode 100644
index 1ca9aecf1..000000000
--- a/src/resources/resourcemanager/resourcemanager.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RESOURCEMANAGER_RESOURCEMANAGER_H
-#define RESOURCES_RESOURCEMANAGER_RESOURCEMANAGER_H
-
-#include "resources/resourcefunctiontypes.h"
-
-#if defined(DEBUG_DUMP_LEAKS) || defined(UNITTESTS)
-#include "resources/resourcetypes.h"
-
-#include <set>
-#endif // defined(DEBUG_DUMP_LEAKS) || defined(UNITTESTS)
-
-#include "localconsts.h"
-
-class Resource;
-
-struct SDL_Surface;
-
-namespace ResourceManager
-{
- /**
- * Cleans up remaining resources, warning about resources
- * that were still referenced.
- */
- void deleteResourceManager();
-
- /**
- * Creates a resource and adds it to the resource map.
- *
- * @param idPath The resource identifier path.
- * @param fun A function for generating the resource.
- * @param data Extra parameters for the generator.
- * @return A valid resource or <code>NULL</code> if the resource could
- * not be generated.
- */
- Resource *get(const std::string &idPath,
- generator fun,
- const void *const data) A_WARN_UNUSED;
-
- Resource *getFromCache(const std::string &idPath) A_WARN_UNUSED;
-
- Resource *getFromCache(const std::string &filename,
- const int variant) A_WARN_UNUSED;
-
- bool addResource(const std::string &idPath,
- Resource *const resource);
-
- /**
- * Releases a resource, placing it in the set of orphaned resources.
- */
- void release(Resource *const res);
-
- void clearDeleted(const bool full = true);
-
- void decRefDelete(Resource *const res);
-
- /**
- * Move resource to deleted resources list.
- */
- void moveToDeleted(Resource *const res);
-
- void scheduleDelete(SDL_Surface *const surface);
-
- void clearScheduled();
-
- /**
- * Deletes the class instance if it exists.
- */
- void deleteInstance();
-
- int size() noexcept2 A_WARN_UNUSED;
-
-#if defined(DEBUG_DUMP_LEAKS) || defined(UNITTESTS)
- Resources &getResources() A_WARN_UNUSED;
-
- Resources &getOrphanedResources() A_WARN_UNUSED;
-
- const std::set<Resource*> &getDeletedResources() A_WARN_UNUSED;
-#endif // defined(DEBUG_DUMP_LEAKS) || defined(UNITTESTS)
-
- bool cleanOrphans(const bool always = false);
-
- void cleanProtected();
-
- bool isInCache(const std::string &idPath) A_WARN_UNUSED;
-
- Resource *getTempResource(const std::string &idPath) A_WARN_UNUSED;
-
- void clearCache();
-
- int calcMemoryLocal();
-
- int calcMemoryChilds(const int level);
-
- int calcMemory(const int level);
-
- void cleanUp(Resource *const resource);
-
- void logResource(const Resource *const res);
-
- void logResources(const std::string &msg);
-} // namespace ResourceManager
-
-#endif // RESOURCES_RESOURCEMANAGER_RESOURCEMANAGER_H
diff --git a/src/resources/resourcetypes.h b/src/resources/resourcetypes.h
deleted file mode 100644
index 6846c91da..000000000
--- a/src/resources/resourcetypes.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_RESOURCETYPES_H
-#define RESOURCES_RESOURCETYPES_H
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-class Resource;
-
-namespace ResourceManager
-{
- typedef std::map<std::string, Resource*> Resources;
- typedef Resources::iterator ResourceIterator;
- typedef Resources::const_iterator ResourceCIterator;
-
-} // namespace ResourceManager
-
-#endif // RESOURCES_RESOURCETYPES_H
diff --git a/src/resources/safeopenglimagehelper.cpp b/src/resources/safeopenglimagehelper.cpp
deleted file mode 100644
index 00e37e9aa..000000000
--- a/src/resources/safeopenglimagehelper.cpp
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/safeopenglimagehelper.h"
-
-#if defined(USE_OPENGL) && !defined(ANDROID)
-
-#include "graphicsmanager.h"
-
-#include "render/mobileopengl2graphics.h"
-#include "render/mobileopenglgraphics.h"
-#include "render/modernopenglgraphics.h"
-#include "render/normalopenglgraphics.h"
-#include "render/safeopenglgraphics.h"
-
-#include "render/opengl/mgl.h"
-#include "render/opengl/mglcheck.h"
-
-#include "resources/dye/dye.h"
-#include "resources/dye/dyepalette.h"
-
-#include "resources/image/image.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-int SafeOpenGLImageHelper::mTextureType = 0;
-int SafeOpenGLImageHelper::mInternalTextureType = GL_RGBA8;
-int SafeOpenGLImageHelper::mTextureSize = 0;
-bool SafeOpenGLImageHelper::mBlur = true;
-bool SafeOpenGLImageHelper::mUseTextureSampler = false;
-
-SafeOpenGLImageHelper::~SafeOpenGLImageHelper()
-{
- glDeleteTextures(static_cast<GLsizei>(texturesSize - mFreeTextureIndex),
- &mTextures[mFreeTextureIndex]);
-}
-
-Image *SafeOpenGLImageHelper::load(SDL_RWops *const rw,
- Dye const &dye)
-{
- SDL_Surface *const tmpImage = loadPng(rw);
- if (tmpImage == nullptr)
- {
- logger->log("Error, image load failed: %s", SDL_GetError());
- return nullptr;
- }
-
- SDL_Surface *const surf = convertTo32Bit(tmpImage);
- MSDL_FreeSurface(tmpImage);
- if (surf == nullptr)
- return nullptr;
-
- uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
- const int type = dye.getType();
-
- switch (type)
- {
- case 1:
- {
- const DyePalette *const pal = dye.getSPalete();
- if (pal != nullptr)
- DYEPALETTEP(pal, SOGLColor)(pixels, surf->w * surf->h);
- break;
- }
- case 2:
- {
- const DyePalette *const pal = dye.getAPalete();
- if (pal != nullptr)
- DYEPALETTEP(pal, AOGLColor)(pixels, surf->w * surf->h);
- break;
- }
- case 0:
- default:
- {
- dye.normalOGLDye(pixels, surf->w * surf->h);
- break;
- }
- }
-
- Image *const image = loadSurface(surf);
- MSDL_FreeSurface(surf);
- return image;
-}
-
-Image *SafeOpenGLImageHelper::loadSurface(SDL_Surface *const tmpImage)
-{
- return glLoad(tmpImage);
-}
-
-Image *SafeOpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
- const int width,
- const int height,
- const float alpha)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
- Image *const img = glLoad(tmpImage, width, height);
- if (img != nullptr)
- img->setAlpha(alpha);
- return img;
-}
-
-int SafeOpenGLImageHelper::powerOfTwo(const int input)
-{
- int value = 1;
- while (value < input && value < mTextureSize)
- value <<= 1;
- return value >= mTextureSize ? mTextureSize : value;
-}
-
-SDL_Surface *SafeOpenGLImageHelper::convertSurfaceNormalize(SDL_Surface
- *tmpImage,
- int width,
- int height)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
- int realWidth = powerOfTwo(width);
- int realHeight = powerOfTwo(height);
-
- if (realWidth < width || realHeight < height)
- {
- logger->log("Warning: image too large, cropping to %dx%d texture!",
- tmpImage->w, tmpImage->h);
- }
-
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else // USE_SDL2
-
- // Make sure the alpha channel is not used, but copied to destination
- SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif // USE_SDL2
-
- // Determine 32-bit masks based on byte order
- uint32_t rmask, gmask, bmask, amask;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (tmpImage->format->BitsPerPixel != 32
- || realWidth != width || realHeight != height
- || rmask != tmpImage->format->Rmask
- || gmask != tmpImage->format->Gmask
- || amask != tmpImage->format->Amask)
- {
- SDL_Surface *oldImage = tmpImage;
-#ifdef USE_SDL2
- SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif // USE_SDL2
-
- tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
- 32, rmask, gmask, bmask, amask);
-
- if (tmpImage == nullptr)
- {
- logger->log("Error, image convert failed: out of memory");
- return nullptr;
- }
- SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
- }
- return tmpImage;
-}
-
-SDL_Surface *SafeOpenGLImageHelper::convertSurface(SDL_Surface *tmpImage,
- int width,
- int height)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
-#else // USE_SDL2
-
- // Make sure the alpha channel is not used, but copied to destination
- SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
-#endif // USE_SDL2
-
- // Determine 32-bit masks based on byte order
- uint32_t rmask, gmask, bmask, amask;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (tmpImage->format->BitsPerPixel != 32
- || rmask != tmpImage->format->Rmask
- || gmask != tmpImage->format->Gmask
- || amask != tmpImage->format->Amask)
- {
- SDL_Surface *oldImage = tmpImage;
-#ifdef USE_SDL2
- SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
-#endif // USE_SDL2
-
- tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
- 32, rmask, gmask, bmask, amask);
-
- if (tmpImage == nullptr)
- {
- logger->log("Error, image convert failed: out of memory");
- return nullptr;
- }
- SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
- }
- return tmpImage;
-}
-
-void SafeOpenGLImageHelper::bindTexture(const GLuint texture)
-{
- switch (mUseOpenGL)
- {
-#ifdef __native_client__
- case RENDER_NORMAL_OPENGL:
- case RENDER_MODERN_OPENGL:
- case RENDER_GLES_OPENGL:
- break;
- case RENDER_SAFE_OPENGL:
- SafeOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_GLES2_OPENGL:
- MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
- break;
-#elif defined(ANDROID)
- case RENDER_NORMAL_OPENGL:
- case RENDER_MODERN_OPENGL:
- case RENDER_SAFE_OPENGL:
- case RENDER_GLES2_OPENGL:
- break;
- case RENDER_GLES_OPENGL:
- MobileOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
-#else // __native_client__
- case RENDER_NORMAL_OPENGL:
- NormalOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_MODERN_OPENGL:
- ModernOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_SAFE_OPENGL:
- SafeOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_GLES_OPENGL:
- MobileOpenGLGraphics::bindTexture(mTextureType, texture);
- break;
- case RENDER_GLES2_OPENGL:
- MobileOpenGL2Graphics::bindTexture(mTextureType, texture);
- break;
-#endif // __native_client__
- case RENDER_SOFTWARE:
- case RENDER_SDL2_DEFAULT:
- case RENDER_NULL:
- case RENDER_LAST:
- default:
- logger->log("Unknown OpenGL backend: %d", mUseOpenGL);
- break;
- }
-}
-
-Image *SafeOpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
- int width,
- int height)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
- BLOCK_START("SafeOpenGLImageHelper::glLoad")
- // Flush current error flag.
- graphicsManager.getLastError();
-
- if (width == 0)
- width = tmpImage->w;
- if (height == 0)
- height = tmpImage->h;
-
- SDL_Surface *oldImage = tmpImage;
- tmpImage = convertSurfaceNormalize(tmpImage, width, height);
- if (tmpImage == nullptr)
- return nullptr;
-
- const int realWidth = tmpImage->w;
- const int realHeight = tmpImage->h;
-
- const GLuint texture = getNewTexture();
- bindTexture(texture);
-
- if (SDL_MUSTLOCK(tmpImage))
- SDL_LockSurface(tmpImage);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- if (!mUseTextureSampler)
- {
- if (mBlur)
- {
- glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
- else
- {
- glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- }
- }
-#ifndef ANDROID
- glTexParameteri(mTextureType, GL_TEXTURE_MAX_LEVEL, 0);
-#endif // ANDROID
-
- glTexImage2D(mTextureType, 0, mInternalTextureType,
- tmpImage->w, tmpImage->h,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->pixels);
-
-#ifdef DEBUG_OPENGL
-/*
- disabled for now, because debugger can't show it
- if (isGLNotNull(mglLabelObject))
- {
- const char *const text = "image text";
- mglLabelObject(GL_TEXTURE, texture, strlen(text), text);
- }
-*/
-#endif // DEBUG_OPENGL
-
-/*
- GLint compressed;
- glGetTexLevelParameteriv(mTextureType, 0,
- GL_TEXTURE_COMPRESSED_ARB, &compressed);
- if (compressed)
- logger->log("image compressed");
- else
- logger->log("image not compressed");
-*/
-
-#ifdef DEBUG_OPENGL_LEAKS
- textures_count ++;
-#endif // DEBUG_OPENGL_LEAKS
-
- if (SDL_MUSTLOCK(tmpImage))
- SDL_UnlockSurface(tmpImage);
-
- if (oldImage != tmpImage)
- MSDL_FreeSurface(tmpImage);
-
- GLenum error = graphicsManager.getLastError();
- if (error != 0u)
- {
- std::string errmsg = GraphicsManager::errorToString(error);
- logger->log("Error: Image GL import failed: %s (%u)",
- errmsg.c_str(), error);
-// return nullptr;
- }
-
- BLOCK_END("SafeOpenGLImageHelper::glLoad")
- return new Image(texture, width, height, realWidth, realHeight);
-}
-
-void SafeOpenGLImageHelper::initTextureSampler(const GLint id)
-{
- if (mBlur)
- {
- mglSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- mglSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
- else
- {
- mglSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- mglSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- }
-}
-
-SDL_Surface *SafeOpenGLImageHelper::create32BitSurface(int width,
- int height) const
-{
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
- const int amask = 0x000000ff;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
- const int amask = 0xff000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- width = powerOfTwo(width);
- height = powerOfTwo(height);
-
- return MSDL_CreateRGBSurface(SDL_SWSURFACE,
- width, height, 32, rmask, gmask, bmask, amask);
-}
-
-GLuint SafeOpenGLImageHelper::getNewTexture()
-{
- GLuint texture = mTextures[mFreeTextureIndex];
- mFreeTextureIndex ++;
- if (mFreeTextureIndex == texturesSize)
- {
- mFreeTextureIndex = 0;
- postInit();
- }
- return texture;
-}
-
-void SafeOpenGLImageHelper::postInit()
-{
- glGenTextures(texturesSize, &mTextures[mFreeTextureIndex]);
-}
-
-void SafeOpenGLImageHelper::invalidate(const GLuint textureId)
-{
- if (isGLNotNull(mglInvalidateTexImage))
- {
- logger->log("invalidate: %u", textureId);
- mglInvalidateTexImage(textureId, 0);
- }
-}
-
-void SafeOpenGLImageHelper::copySurfaceToImage(const Image *const image,
- const int x,
- const int y,
- SDL_Surface *surface) const
-{
- if (surface == nullptr || image == nullptr)
- return;
-
- SDL_Surface *const oldSurface = surface;
- surface = convertSurface(surface, surface->w, surface->h);
- if (surface == nullptr)
- return;
-
- // +++ probably need combine
- // mglTextureSubImage2D and mglTextureSubImage2DEXT
- if (mglTextureSubImage2D != nullptr)
- {
- mglTextureSubImage2D(image->mGLImage,
- 0,
- x, y,
- surface->w, surface->h,
- GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
- }
- else
- {
- mglTextureSubImage2DEXT(image->mGLImage,
- mTextureType, 0,
- x, y,
- surface->w, surface->h,
- GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
- }
-
- if (surface != oldSurface)
- MSDL_FreeSurface(surface);
-}
-
-#endif // defined(USE_OPENGL) && !defined(ANDROID)
diff --git a/src/resources/safeopenglimagehelper.h b/src/resources/safeopenglimagehelper.h
deleted file mode 100644
index 7d551cc36..000000000
--- a/src/resources/safeopenglimagehelper.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SAFEOPENGLIMAGEHELPER_H
-#define RESOURCES_SAFEOPENGLIMAGEHELPER_H
-
-#include "localconsts.h"
-
-#if defined(USE_OPENGL) && !defined(ANDROID)
-
-#ifndef GL_TEXTURE_RECTANGLE_ARB
-#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
-#endif // GL_TEXTURE_RECTANGLE_ARB
-
-#include "resources/imagehelper.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#define GL_RGBA8 GL_RGBA8_OES
-#else // ANDROID
-#ifndef USE_SDL2
-#define GL_GLEXT_PROTOTYPES 1
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_opengl.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // ANDROID
-
-class Dye;
-class Image;
-
-/**
- * Defines a class for loading and storing images.
- */
-class SafeOpenGLImageHelper final : public ImageHelper
-{
- friend class CompoundSprite;
- friend class Graphics;
- friend class Image;
-
- public:
- SafeOpenGLImageHelper() :
- mFreeTextureIndex(0U),
- mTextures()
- {
- }
-
- A_DELETE_COPY(SafeOpenGLImageHelper)
-
- ~SafeOpenGLImageHelper();
-
- /**
- * Loads an image from an SDL_RWops structure and recolors it.
- *
- * @param rw The SDL_RWops to load the image from.
- * @param dye The dye used to recolor the image.
- *
- * @return <code>NULL</code> if an error occurred, a valid pointer
- * otherwise.
- */
- Image *load(SDL_RWops *const rw,
- Dye const &dye) override final A_WARN_UNUSED;
-
- /**
- * Loads an image from an SDL surface.
- */
- Image *loadSurface(SDL_Surface *const tmpImage)
- override final A_WARN_UNUSED;
-
- Image *createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- const float alpha)
- override final A_WARN_UNUSED;
-
- // OpenGL only public functions
-
- static int getTextureType() A_WARN_UNUSED
- { return mTextureType; }
-
- static int getInternalTextureType() A_WARN_UNUSED
- { return mInternalTextureType; }
-
- constexpr2 static void setInternalTextureType(const int n) noexcept2
- { mInternalTextureType = n; }
-
- constexpr2 static void setBlur(const bool n) noexcept2
- { mBlur = n; }
-
- static int mTextureType;
-
- static int mInternalTextureType;
-
- static int getTextureSize() noexcept2 A_WARN_UNUSED
- { return mTextureSize; }
-
- static void initTextureSampler(const GLint id);
-
- constexpr2 static void setUseTextureSampler(const bool b) noexcept2
- { mUseTextureSampler = b; }
-
- static void invalidate(const GLuint textureId);
-
- static void bindTexture(const GLuint texture);
-
- SDL_Surface *create32BitSurface(int width,
- int height) const override final;
-
- void postInit() override final;
-
- void copySurfaceToImage(const Image *const image,
- const int x, const int y,
- SDL_Surface *surface) const override final;
-
- protected:
- /**
- * Returns the first power of two equal or bigger than the input.
- */
- static int powerOfTwo(const int input) A_WARN_UNUSED;
-
- static SDL_Surface *convertSurfaceNormalize(SDL_Surface *tmpImage,
- int width, int height);
-
- static SDL_Surface *convertSurface(SDL_Surface *tmpImage,
- int width, int height);
-
- Image *glLoad(SDL_Surface *tmpImage,
- int width = 0, int height = 0) A_WARN_UNUSED;
-
- GLuint getNewTexture();
-
- static const size_t texturesSize = 10;
- size_t mFreeTextureIndex;
- GLuint mTextures[texturesSize];
-
- static int mTextureSize;
- static bool mBlur;
- static bool mUseTextureSampler;
-};
-
-#endif // defined(USE_OPENGL) && !defined(ANDROID)
-#endif // RESOURCES_SAFEOPENGLIMAGEHELPER_H
diff --git a/src/resources/screenshothelper.h b/src/resources/screenshothelper.h
deleted file mode 100644
index 25a8443d9..000000000
--- a/src/resources/screenshothelper.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SCREENSHOTHELPER_H
-#define RESOURCES_SCREENSHOTHELPER_H
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_video.h>
-PRAGMA48(GCC diagnostic pop)
-
-class ScreenshotHelper notfinal
-{
- public:
- ScreenshotHelper()
- { }
-
- A_DELETE_COPY(ScreenshotHelper)
-
- virtual ~ScreenshotHelper()
- { }
-
- virtual void prepare() = 0;
-
- virtual SDL_Surface *getScreenshot() = 0;
-};
-
-extern ScreenshotHelper *screenshortHelper;
-
-#endif // RESOURCES_SCREENSHOTHELPER_H
diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp
deleted file mode 100644
index 1e8c12cdc..000000000
--- a/src/resources/sdl2imagehelper.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_SDL2
-
-#include "resources/sdl2imagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/checkutils.h"
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-bool SDLImageHelper::mEnableAlphaCache = false;
-SDL_Renderer *SDLImageHelper::mRenderer = nullptr;
-
-Image *SDLImageHelper::loadSurface(SDL_Surface *const tmpImage)
-{
- return _SDLload(tmpImage);
-}
-
-Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
- const int width A_UNUSED,
- const int height A_UNUSED,
- const float alpha)
-{
- if (!tmpImage)
- return nullptr;
-
- Image *const img = _SDLload(tmpImage);
- if (img)
- img->setAlpha(alpha);
- return img;
-}
-
-SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage)
-{
- if (!tmpImage || !tmpImage->format)
- return nullptr;
-
- return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
-}
-
-Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
-{
- if (!tmpImage)
- return nullptr;
-
- SDL_Texture *const texture = SDL_CreateTextureFromSurface(
- mRenderer, tmpImage);
- if (!texture)
- {
- reportAlways("Texture from surface creation failed: %s",
- SDL_GetError());
- return nullptr;
- }
- SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
- return new Image(texture, tmpImage->w, tmpImage->h);
-}
-
-int SDLImageHelper::combineSurface(SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- SDL_Surface *restrict const dst,
- SDL_Rect *restrict const dstrect)
-{
- SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND);
- SDL_BlitSurface(src, srcrect, dst, dstrect);
- return 1;
-}
-
-void SDLImageHelper::copySurfaceToImage(const Image *const image,
- const int x, const int y,
- SDL_Surface *const surface) const
-{
- if (!image || !surface)
- return;
-
- SDL_SetSurfaceAlphaMod(surface, SDL_ALPHA_OPAQUE);
- SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
-
- SDL_Rect rect =
- {
- x, y,
- surface->w, surface->h
- };
-
- SDL_BlitSurface(surface, nullptr, image->mSDLSurface, &rect);
-}
-#endif // USE_SDL2
diff --git a/src/resources/sdl2imagehelper.h b/src/resources/sdl2imagehelper.h
deleted file mode 100644
index dab36e038..000000000
--- a/src/resources/sdl2imagehelper.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SDL2IMAGEHELPER_H
-#define RESOURCES_SDL2IMAGEHELPER_H
-
-#ifdef USE_SDL2
-
-#include "localconsts.h"
-
-#include "resources/imagehelper.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
-class Dye;
-class Image;
-
-/**
- * Defines a class for loading and storing images.
- */
-class SDLImageHelper final : public ImageHelper
-{
- friend class Image;
-
- public:
- SDLImageHelper() :
- ImageHelper()
- { }
-
- A_DELETE_COPY(SDLImageHelper)
-
- ~SDLImageHelper()
- { }
-
- /**
- * Loads an image from an SDL surface.
- */
- Image *loadSurface(SDL_Surface *const tmpImage) override final
- A_WARN_UNUSED;
-
- Image *createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- const float alpha)
- override final A_WARN_UNUSED;
-
- void copySurfaceToImage(const Image *const image,
- const int x, const int y,
- SDL_Surface *const surface)
- const override final;
-
- constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2
- { mEnableAlphaCache = n; }
-
- static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
- { return mEnableAlphaCache; }
-
- static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
- A_WARN_UNUSED;
-
- static int combineSurface(SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- SDL_Surface *restrict const dst,
- SDL_Rect *restrict const dstrect);
-
- constexpr2 static void setRenderer(SDL_Renderer *const renderer)
- noexcept2
- { mRenderer = renderer; }
-
- protected:
- /** SDL_Surface to SDL_Surface Image loader */
- Image *_SDLload(SDL_Surface *tmpImage) A_WARN_UNUSED;
-
- static bool mEnableAlphaCache;
- static SDL_Renderer *mRenderer;
-};
-
-#endif // USE_SDL2
-#endif // RESOURCES_SDL2IMAGEHELPER_H
diff --git a/src/resources/sdl2softwareimagehelper.cpp b/src/resources/sdl2softwareimagehelper.cpp
deleted file mode 100644
index 654b383b9..000000000
--- a/src/resources/sdl2softwareimagehelper.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_SDL2
-
-#include "resources/sdl2softwareimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-bool SDL2SoftwareImageHelper::mEnableAlphaCache = false;
-SDL_PixelFormat *SDL2SoftwareImageHelper::mFormat = nullptr;
-
-Image *SDL2SoftwareImageHelper::loadSurface(SDL_Surface *const tmpImage)
-{
- return _SDLload(tmpImage);
-}
-
-Image *SDL2SoftwareImageHelper::createTextSurface(SDL_Surface *const tmpImage,
- const int width A_UNUSED,
- const int height A_UNUSED,
- const float alpha)
-{
- if (!tmpImage)
- return nullptr;
-
- Image *const img = _SDLload(tmpImage);
- if (img)
- img->setAlpha(alpha);
- return img;
-}
-
-SDL_Surface* SDL2SoftwareImageHelper::SDLDuplicateSurface(SDL_Surface *const
- tmpImage)
-{
- if (!tmpImage || !tmpImage->format)
- return nullptr;
-
- return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
-}
-
-Image *SDL2SoftwareImageHelper::_SDLload(SDL_Surface *tmpImage)
-{
- if (!tmpImage)
- return nullptr;
-
- SDL_Surface *image = SDL_ConvertSurface(tmpImage, mFormat, 0);
- return new Image(image, false, nullptr);
-}
-
-int SDL2SoftwareImageHelper::combineSurface(SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- SDL_Surface *restrict const dst,
- SDL_Rect *restrict const dstrect)
-{
- SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND);
- SDL_BlitSurface(src, srcrect, dst, dstrect);
- return 1;
-}
-
-#endif // USE_SDL2
diff --git a/src/resources/sdl2softwareimagehelper.h b/src/resources/sdl2softwareimagehelper.h
deleted file mode 100644
index e2795f0a4..000000000
--- a/src/resources/sdl2softwareimagehelper.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SDL2SOFTWAREIMAGEHELPER_H
-#define RESOURCES_SDL2SOFTWAREIMAGEHELPER_H
-
-#ifdef USE_SDL2
-
-#include "localconsts.h"
-
-#include "resources/imagehelper.h"
-
-class Dye;
-class Image;
-
-/**
- * Defines a class for loading and storing images.
- */
-class SDL2SoftwareImageHelper final : public ImageHelper
-{
- friend class Image;
-
- public:
- SDL2SoftwareImageHelper() :
- ImageHelper()
- { }
-
- A_DELETE_COPY(SDL2SoftwareImageHelper)
-
- ~SDL2SoftwareImageHelper()
- { }
-
- /**
- * Loads an image from an SDL surface.
- */
- Image *loadSurface(SDL_Surface *const tmpImage) override final
- A_WARN_UNUSED;
-
- Image *createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- const float alpha)
- override final A_WARN_UNUSED;
-
- constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2
- { mEnableAlphaCache = n; }
-
- static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
- { return mEnableAlphaCache; }
-
- static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
- A_WARN_UNUSED;
-
- static int combineSurface(SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- SDL_Surface *restrict const dst,
- SDL_Rect *restrict const dstrect);
-
- static void setFormat(SDL_PixelFormat *const format) noexcept2
- {
- mFormat = format;
- if (mFormat)
- {
- mFormat->Amask = ~(format->Rmask
- | format->Gmask | format->Bmask);
- }
- }
-
- protected:
- /** SDL_Surface to SDL_Surface Image loader */
- Image *_SDLload(SDL_Surface *tmpImage) A_WARN_UNUSED;
-
- static bool mEnableAlphaCache;
- static SDL_PixelFormat *mFormat;
-};
-
-#endif // USE_SDL2
-#endif // RESOURCES_SDL2SOFTWAREIMAGEHELPER_H
diff --git a/src/resources/sdl2softwarescreenshothelper.cpp b/src/resources/sdl2softwarescreenshothelper.cpp
deleted file mode 100644
index 58f19cde1..000000000
--- a/src/resources/sdl2softwarescreenshothelper.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_SDL2
-
-#include "resources/sdl2softwarescreenshothelper.h"
-
-#include "render/sdl2softwaregraphics.h"
-
-#include "utils/sdlcheckutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-Sdl2SoftwareScreenshotHelper::Sdl2SoftwareScreenshotHelper() :
- ScreenshotHelper()
-{
-}
-
-Sdl2SoftwareScreenshotHelper::~Sdl2SoftwareScreenshotHelper()
-{
-}
-
-void Sdl2SoftwareScreenshotHelper::prepare()
-{
-}
-
-SDL_Surface *Sdl2SoftwareScreenshotHelper::getScreenshot()
-{
- if (!mainGraphics)
- return nullptr;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int amask = 0x00000000;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
- mainGraphics->mWidth, mainGraphics->mHeight,
- 24,
- rmask, gmask, bmask, amask);
-
- if (screenshot)
- {
- SDL_BlitSurface(static_cast<SDL2SoftwareGraphics*>(
- mainGraphics)->mSurface, nullptr, screenshot, nullptr);
- }
-
- return screenshot;
-}
-
-#endif // USE_SDL2
diff --git a/src/resources/sdl2softwarescreenshothelper.h b/src/resources/sdl2softwarescreenshothelper.h
deleted file mode 100644
index 872676729..000000000
--- a/src/resources/sdl2softwarescreenshothelper.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SDL2SOFTWARESCREENSHOTHELPER_H
-#define RESOURCES_SDL2SOFTWARESCREENSHOTHELPER_H
-
-#ifdef USE_SDL2
-
-#include "resources/screenshothelper.h"
-
-#include "localconsts.h"
-
-class Sdl2SoftwareScreenshotHelper final : public ScreenshotHelper
-{
- public:
- Sdl2SoftwareScreenshotHelper();
-
- A_DELETE_COPY(Sdl2SoftwareScreenshotHelper)
-
- ~Sdl2SoftwareScreenshotHelper();
-
- void prepare() override final;
-
- SDL_Surface *getScreenshot() override final;
-};
-
-#endif // USE_SDL2
-#endif // RESOURCES_SDL2SOFTWARESCREENSHOTHELPER_H
diff --git a/src/resources/sdlgfxblitfunc.cpp b/src/resources/sdlgfxblitfunc.cpp
deleted file mode 100644
index d5e3268c7..000000000
--- a/src/resources/sdlgfxblitfunc.cpp
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
-
-SDL_gfxBlitFunc: custom blitters (part of SDL_gfx library)
-
-LGPL (c) A. Schiffler
-
-*/
-
-#ifndef USE_SDL2
-#include "resources/sdlgfxblitfunc.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_video.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#define GFX_DUFFS_LOOP4(pixel_copy_increment, width) \
- int n = (width + 3) / 4; \
- switch (width & 3) \
- { \
- case 0: do { \
- pixel_copy_increment; \
- case 3: pixel_copy_increment; \
- case 2: pixel_copy_increment; \
- case 1: pixel_copy_increment; \
- default: ; \
- } while (--n > 0 ); \
- }
-
-namespace
-{
- struct SDL_gfxBlitInfo final
- {
- A_DEFAULT_COPY(SDL_gfxBlitInfo)
-
- Uint8 *s_pixels;
- int s_width;
- int s_height;
- int s_skip;
- Uint8 *d_pixels;
- int d_width;
- int d_height;
- int d_skip;
- void *aux_data;
- SDL_PixelFormat *src;
- Uint8 *table;
- SDL_PixelFormat *dst;
- };
-
- unsigned int GFX_ALPHA_ADJUST_ARRAY[256] =
- {
- 0, /* 0 */
- 15, /* 1 */
- 22, /* 2 */
- 27, /* 3 */
- 31, /* 4 */
- 35, /* 5 */
- 39, /* 6 */
- 42, /* 7 */
- 45, /* 8 */
- 47, /* 9 */
- 50, /* 10 */
- 52, /* 11 */
- 55, /* 12 */
- 57, /* 13 */
- 59, /* 14 */
- 61, /* 15 */
- 63, /* 16 */
- 65, /* 17 */
- 67, /* 18 */
- 69, /* 19 */
- 71, /* 20 */
- 73, /* 21 */
- 74, /* 22 */
- 76, /* 23 */
- 78, /* 24 */
- 79, /* 25 */
- 81, /* 26 */
- 82, /* 27 */
- 84, /* 28 */
- 85, /* 29 */
- 87, /* 30 */
- 88, /* 31 */
- 90, /* 32 */
- 91, /* 33 */
- 93, /* 34 */
- 94, /* 35 */
- 95, /* 36 */
- 97, /* 37 */
- 98, /* 38 */
- 99, /* 39 */
- 100, /* 40 */
- 102, /* 41 */
- 103, /* 42 */
- 104, /* 43 */
- 105, /* 44 */
- 107, /* 45 */
- 108, /* 46 */
- 109, /* 47 */
- 110, /* 48 */
- 111, /* 49 */
- 112, /* 50 */
- 114, /* 51 */
- 115, /* 52 */
- 116, /* 53 */
- 117, /* 54 */
- 118, /* 55 */
- 119, /* 56 */
- 120, /* 57 */
- 121, /* 58 */
- 122, /* 59 */
- 123, /* 60 */
- 124, /* 61 */
- 125, /* 62 */
- 126, /* 63 */
- 127, /* 64 */
- 128, /* 65 */
- 129, /* 66 */
- 130, /* 67 */
- 131, /* 68 */
- 132, /* 69 */
- 133, /* 70 */
- 134, /* 71 */
- 135, /* 72 */
- 136, /* 73 */
- 137, /* 74 */
- 138, /* 75 */
- 139, /* 76 */
- 140, /* 77 */
- 141, /* 78 */
- 141, /* 79 */
- 142, /* 80 */
- 143, /* 81 */
- 144, /* 82 */
- 145, /* 83 */
- 146, /* 84 */
- 147, /* 85 */
- 148, /* 86 */
- 148, /* 87 */
- 149, /* 88 */
- 150, /* 89 */
- 151, /* 90 */
- 152, /* 91 */
- 153, /* 92 */
- 153, /* 93 */
- 154, /* 94 */
- 155, /* 95 */
- 156, /* 96 */
- 157, /* 97 */
- 158, /* 98 */
- 158, /* 99 */
- 159, /* 100 */
- 160, /* 101 */
- 161, /* 102 */
- 162, /* 103 */
- 162, /* 104 */
- 163, /* 105 */
- 164, /* 106 */
- 165, /* 107 */
- 165, /* 108 */
- 166, /* 109 */
- 167, /* 110 */
- 168, /* 111 */
- 168, /* 112 */
- 169, /* 113 */
- 170, /* 114 */
- 171, /* 115 */
- 171, /* 116 */
- 172, /* 117 */
- 173, /* 118 */
- 174, /* 119 */
- 174, /* 120 */
- 175, /* 121 */
- 176, /* 122 */
- 177, /* 123 */
- 177, /* 124 */
- 178, /* 125 */
- 179, /* 126 */
- 179, /* 127 */
- 180, /* 128 */
- 181, /* 129 */
- 182, /* 130 */
- 182, /* 131 */
- 183, /* 132 */
- 184, /* 133 */
- 184, /* 134 */
- 185, /* 135 */
- 186, /* 136 */
- 186, /* 137 */
- 187, /* 138 */
- 188, /* 139 */
- 188, /* 140 */
- 189, /* 141 */
- 190, /* 142 */
- 190, /* 143 */
- 191, /* 144 */
- 192, /* 145 */
- 192, /* 146 */
- 193, /* 147 */
- 194, /* 148 */
- 194, /* 149 */
- 195, /* 150 */
- 196, /* 151 */
- 196, /* 152 */
- 197, /* 153 */
- 198, /* 154 */
- 198, /* 155 */
- 199, /* 156 */
- 200, /* 157 */
- 200, /* 158 */
- 201, /* 159 */
- 201, /* 160 */
- 202, /* 161 */
- 203, /* 162 */
- 203, /* 163 */
- 204, /* 164 */
- 205, /* 165 */
- 205, /* 166 */
- 206, /* 167 */
- 206, /* 168 */
- 207, /* 169 */
- 208, /* 170 */
- 208, /* 171 */
- 209, /* 172 */
- 210, /* 173 */
- 210, /* 174 */
- 211, /* 175 */
- 211, /* 176 */
- 212, /* 177 */
- 213, /* 178 */
- 213, /* 179 */
- 214, /* 180 */
- 214, /* 181 */
- 215, /* 182 */
- 216, /* 183 */
- 216, /* 184 */
- 217, /* 185 */
- 217, /* 186 */
- 218, /* 187 */
- 218, /* 188 */
- 219, /* 189 */
- 220, /* 190 */
- 220, /* 191 */
- 221, /* 192 */
- 221, /* 193 */
- 222, /* 194 */
- 222, /* 195 */
- 223, /* 196 */
- 224, /* 197 */
- 224, /* 198 */
- 225, /* 199 */
- 225, /* 200 */
- 226, /* 201 */
- 226, /* 202 */
- 227, /* 203 */
- 228, /* 204 */
- 228, /* 205 */
- 229, /* 206 */
- 229, /* 207 */
- 230, /* 208 */
- 230, /* 209 */
- 231, /* 210 */
- 231, /* 211 */
- 232, /* 212 */
- 233, /* 213 */
- 233, /* 214 */
- 234, /* 215 */
- 234, /* 216 */
- 235, /* 217 */
- 235, /* 218 */
- 236, /* 219 */
- 236, /* 220 */
- 237, /* 221 */
- 237, /* 222 */
- 238, /* 223 */
- 238, /* 224 */
- 239, /* 225 */
- 240, /* 226 */
- 240, /* 227 */
- 241, /* 228 */
- 241, /* 229 */
- 242, /* 230 */
- 242, /* 231 */
- 243, /* 232 */
- 243, /* 233 */
- 244, /* 234 */
- 244, /* 235 */
- 245, /* 236 */
- 245, /* 237 */
- 246, /* 238 */
- 246, /* 239 */
- 247, /* 240 */
- 247, /* 241 */
- 248, /* 242 */
- 248, /* 243 */
- 249, /* 244 */
- 249, /* 245 */
- 250, /* 246 */
- 250, /* 247 */
- 251, /* 248 */
- 251, /* 249 */
- 252, /* 250 */
- 252, /* 251 */
- 253, /* 252 */
- 253, /* 253 */
- 254, /* 254 */
- 255 /* 255 */
- };
-} // namespace
-
-static void _SDL_gfxBlitBlitterRGBA(const SDL_gfxBlitInfo *const info)
-{
- const int width = info->d_width;
- int height = info->d_height;
- Uint8 *src = info->s_pixels;
- const int srcskip = info->s_skip;
- Uint8 *dst = info->d_pixels;
- const int dstskip = info->d_skip;
- const SDL_PixelFormat *const srcfmt = info->src;
-
- while ((height--) != 0)
- {
- GFX_DUFFS_LOOP4(
- {
- Uint32 pixel;
- uint32_t sR;
- uint32_t sG;
- uint32_t sB;
- uint32_t sA;
- uint32_t dR;
- uint32_t dG;
- uint32_t dB;
- uint32_t dA;
- uint32_t sAA;
-
- pixel = *(reinterpret_cast<uint32_t *>(src));
- sR = ((pixel & srcfmt->Rmask) >> srcfmt->Rshift);
- sG = ((pixel & srcfmt->Gmask) >> srcfmt->Gshift);
- sB = ((pixel & srcfmt->Bmask) >> srcfmt->Bshift);
- sA = ((pixel & srcfmt->Amask) >> srcfmt->Ashift);
-
- pixel = *(reinterpret_cast<uint32_t *>(dst));
- dR = pixel & 0xff;
- dG = ((pixel & 0xff00) >> 8);
- dB = ((pixel & 0xff0000) >> 16);
- dA = ((pixel & 0xff000000) >> 24);
-
- sAA = GFX_ALPHA_ADJUST_ARRAY[sA & 255];
- dR = (((sR - dR) * (sAA)) / 255) + dR;
- dG = (((sG - dG) * (sAA)) / 255) + dG;
- dB = (((sB - dB) * (sAA)) / 255) + dB;
- dA |= sAA;
-
- *(reinterpret_cast<uint32_t *>(dst)) = dR |
- (dG << 8) |
- (dB << 16) |
- (dA << 24);
-
- src += 4;
- dst += 4;
- }, width);
- src += srcskip;
- dst += dstskip;
- }
-}
-
-static int _SDL_gfxBlitRGBACall(const SDL_Surface *const src,
- const SDL_Rect *const srcrect,
- const SDL_Surface *const dst,
- const SDL_Rect *const dstrect)
-{
- /*
- * Set up source and destination buffer pointers, then blit
- */
- if ((srcrect->w != 0u) && (srcrect->h != 0u))
- {
- SDL_gfxBlitInfo info;
-
- /*
- * Set up the blit information
- */
- info.s_pixels = static_cast<Uint8 *>(src->pixels) + src->offset +
- static_cast<Uint16>(srcrect->y) * src->pitch +
- static_cast<Uint16>(srcrect->x) * src->format->BytesPerPixel;
- info.s_width = srcrect->w;
- info.s_height = srcrect->h;
- info.s_skip = CAST_S32(src->pitch - info.s_width *
- src->format->BytesPerPixel);
- info.d_pixels = static_cast<Uint8 *>(dst->pixels) + dst->offset +
- static_cast<Uint16>(dstrect->y) * dst->pitch +
- static_cast<Uint16>(dstrect->x) * dst->format->BytesPerPixel;
- info.d_width = dstrect->w;
- info.d_height = dstrect->h;
- info.d_skip = CAST_S32(dst->pitch - info.d_width *
- dst->format->BytesPerPixel);
- info.aux_data = nullptr;
- info.src = src->format;
- info.table = nullptr;
- info.dst = dst->format;
-
- /*
- * Run the actual software blitter
- */
- _SDL_gfxBlitBlitterRGBA(&info);
- return 1;
- }
-
- return 0;
-}
-
-int SDLgfxBlitRGBA(SDL_Surface *const src,
- const SDL_Rect *const srcrect,
- SDL_Surface *const dst,
- const SDL_Rect *const dstrect)
-{
- SDL_Rect sr;
- SDL_Rect dr;
- int srcx;
- int srcy;
- int w;
- int h;
-
- /*
- * Make sure the surfaces aren't locked
- */
- if (src == nullptr ||
- dst == nullptr)
- {
- reportAlways("SDLgfxBlitRGBA: passed a NULL surface");
- return -1;
- }
-
- /*
- * If the destination rectangle is NULL, use the entire dest surface
- */
- if (dstrect == nullptr)
- {
- dr.x = 0;
- dr.y = 0;
- dr.w = CAST_U16(dst->w);
- dr.h = CAST_U16(dst->h);
- }
- else
- {
- dr = *dstrect;
- }
-
- /*
- * Clip the source rectangle to the source surface
- */
- if (srcrect != nullptr)
- {
- int maxw;
- int maxh;
-
- srcx = srcrect->x;
- w = srcrect->w;
- maxw = src->w - srcx;
- if (maxw < w)
- w = maxw;
-
- srcy = srcrect->y;
- h = srcrect->h;
- maxh = src->h - srcy;
- if (maxh < h)
- h = maxh;
- }
- else
- {
- srcx = 0;
- srcy = 0;
- w = src->w;
- h = src->h;
- }
-
- /*
- * Clip the destination rectangle against the clip rectangle
- */
- const SDL_Rect *const clip = &dst->clip_rect;
- int dx;
- int dy;
-
- dx = clip->x - dr.x;
- if (dx > 0)
- {
- w -= dx;
- dr.x += dx;
- srcx += CAST_S16(dx);
- }
- dx = dr.x + w - clip->x - clip->w;
- if (dx > 0)
- w -= dx;
-
- dy = clip->y - dr.y;
- if (dy > 0)
- {
- h -= dy;
- dr.y += dy;
- srcy += CAST_S16(dy);
- }
- dy = dr.y + h - clip->y - clip->h;
- if (dy > 0)
- h -= dy;
-
- if (w > 0 && h > 0)
- {
- sr.x = CAST_S16(srcx);
- sr.y = CAST_S16(srcy);
- sr.w = dr.w = CAST_U16(w);
- sr.h = dr.h = CAST_U16(h);
- return _SDL_gfxBlitRGBACall(src, &sr, dst, &dr);
- }
-
- return 0;
-}
-
-#endif // USE_SDL2
diff --git a/src/resources/sdlgfxblitfunc.h b/src/resources/sdlgfxblitfunc.h
deleted file mode 100644
index 77a0d1e42..000000000
--- a/src/resources/sdlgfxblitfunc.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
-
-SDL_gfxBlitFunc: custom blitters (part of SDL_gfx library)
-
-LGPL (c) A. Schiffler
-
-*/
-
-#ifndef RESOURCE_SDLGFXBLITFUNC_H
-#define RESOURCE_SDLGFXBLITFUNC_H
-
-struct SDL_Surface;
-struct SDL_Rect;
-
-// src surface can be any format (most time 32 bit surface with any masks)
-// dst surface always correct 32 sufraces (shared format for all)
-int SDLgfxBlitRGBA(SDL_Surface *const src,
- const SDL_Rect *const srcrect,
- SDL_Surface *const dst,
- const SDL_Rect *const dstrect);
-
-#endif // RESOURCE_SDLGFXBLITFUNC_H
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
deleted file mode 100644
index d941931e4..000000000
--- a/src/resources/sdlimagehelper.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef USE_SDL2
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/dye/dye.h"
-#include "resources/dye/dyepalette.h"
-
-#include "resources/image/image.h"
-
-#include "utils/checkutils.h"
-#include "utils/sdlcheckutils.h"
-
-#include "localconsts.h"
-
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-#include "resources/sdlgfxblitfunc.h"
-#else // SDL_BYTEORDER == SDL_LIL_ENDIAN
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_gfxBlitFunc.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-#include "debug.h"
-
-bool SDLImageHelper::mEnableAlphaCache = false;
-
-Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
-{
- SDL_Surface *const tmpImage = loadPng(rw);
- if (tmpImage == nullptr)
- {
- reportAlways("Error, image load failed: %s",
- SDL_GetError());
- return nullptr;
- }
-
- SDL_PixelFormat rgba;
- rgba.palette = nullptr;
- rgba.BitsPerPixel = 32;
- rgba.BytesPerPixel = 4;
- rgba.colorkey = 0;
- rgba.alpha = 255;
- rgba.Rloss = 0;
- rgba.Gloss = 0;
- rgba.Bloss = 0;
- rgba.Aloss = 0;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rgba.Rmask = 0x000000FF;
- rgba.Rshift = 24;
- rgba.Gmask = 0x0000FF00;
- rgba.Gshift = 16;
- rgba.Bmask = 0x00FF0000;
- rgba.Bshift = 8;
- rgba.Amask = 0xFF000000;
- rgba.Ashift = 0;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- rgba.Rmask = 0xFF000000;
- rgba.Rshift = 0;
- rgba.Gmask = 0x00FF0000;
- rgba.Gshift = 8;
- rgba.Bmask = 0x0000FF00;
- rgba.Bshift = 16;
- rgba.Amask = 0x000000FF;
- rgba.Ashift = 24;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- // +++ here is bug on ppc64le
- SDL_Surface *const surf = MSDL_ConvertSurface(
- tmpImage, &rgba, SDL_SWSURFACE);
-
- MSDL_FreeSurface(tmpImage);
- if (surf == nullptr)
- return nullptr;
-
- uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
- const int type = dye.getType();
-
- switch (type)
- {
- case 1:
- {
- const DyePalette *const pal = dye.getSPalete();
- if (pal != nullptr)
- DYEPALETTEP(pal, SColor)(pixels, surf->w * surf->h);
- break;
- }
- case 2:
- {
- const DyePalette *const pal = dye.getAPalete();
- if (pal != nullptr)
- DYEPALETTEP(pal, AColor)(pixels, surf->w * surf->h);
- break;
- }
- case 0:
- default:
- {
- dye.normalDye(pixels, surf->w * surf->h);
- break;
- }
- }
-
- Image *const image = loadSurface(surf);
- MSDL_FreeSurface(surf);
- return image;
-}
-
-Image *SDLImageHelper::loadSurface(SDL_Surface *const tmpImage)
-{
- return _SDLload(tmpImage);
-}
-
-Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
- const int width A_UNUSED,
- const int height A_UNUSED,
- const float alpha)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
- bool hasAlpha = false;
- const size_t sz = tmpImage->w * tmpImage->h;
-
- // The alpha channel to be filled with alpha values
- uint8_t *alphaChannel = new uint8_t[sz];
-
- const SDL_PixelFormat *const fmt = tmpImage->format;
- if (fmt->Amask != 0u)
- {
- for (size_t i = 0; i < sz; ++ i)
- {
- uint32_t c = (static_cast<uint32_t*>(tmpImage->pixels))[i];
-
- const unsigned v = (c & fmt->Amask) >> fmt->Ashift;
- const uint8_t a = static_cast<uint8_t>((v << fmt->Aloss)
- + (v >> (8 - (fmt->Aloss << 1))));
-
- const uint8_t a2 = CAST_U8(
- static_cast<float>(a) * alpha);
-
- c &= ~fmt->Amask;
- c |= ((a2 >> fmt->Aloss) << fmt->Ashift & fmt->Amask);
- (static_cast<uint32_t*>(tmpImage->pixels))[i] = c;
-
- if (a != 255)
- hasAlpha = true;
-
- alphaChannel[i] = a;
- }
- }
-
- SDL_Surface *image;
-
- // Convert the surface to the current display format
- if (hasAlpha)
- {
- image = MSDL_DisplayFormatAlpha(tmpImage);
- }
- else
- {
- image = MSDL_DisplayFormat(tmpImage);
-
- // We also delete the alpha channel since
- // it's not used.
- delete [] alphaChannel;
- alphaChannel = nullptr;
- }
-
- if (image == nullptr)
- {
- reportAlways("Error: Image convert failed.");
- delete [] alphaChannel;
- return nullptr;
- }
-
- Image *const img = new Image(image, hasAlpha, alphaChannel);
- img->mAlpha = alpha;
- return img;
-}
-
-SDL_Surface* SDLImageHelper::SDLDuplicateSurface(SDL_Surface *const tmpImage)
-{
- if ((tmpImage == nullptr) || (tmpImage->format == nullptr))
- return nullptr;
-
- return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
-}
-
-Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
-{
- if (tmpImage == nullptr)
- return nullptr;
-
- bool hasAlpha = false;
- bool converted = false;
-
- if (tmpImage->format->BitsPerPixel != 32)
- {
- reportAlways("Non 32 bit image detected");
- tmpImage = convertTo32Bit(tmpImage);
-
- if (tmpImage == nullptr)
- return nullptr;
- converted = true;
- }
-
- const size_t sz = tmpImage->w * tmpImage->h;
-
- // The alpha channel to be filled with alpha values
- uint8_t *alphaChannel = new uint8_t[sz];
-
- // Figure out whether the image uses its alpha layer
- if (tmpImage->format->palette == nullptr)
- {
- const SDL_PixelFormat *const fmt = tmpImage->format;
- if (fmt->Amask != 0u)
- {
- const uint32_t amask = fmt->Amask;
- const uint8_t ashift = fmt->Ashift;
- const uint8_t aloss = fmt->Aloss;
- const uint32_t *pixels = static_cast<uint32_t*>(tmpImage->pixels);
- cilk_for (size_t i = 0; i < sz; ++ i)
- {
- const unsigned v = (pixels[i] & amask) >> ashift;
- const uint8_t a = static_cast<uint8_t>((v << aloss)
- + (v >> (8 - (aloss << 1))));
-
- if (a != 255)
- hasAlpha = true;
-
- alphaChannel[i] = a;
- }
- }
- else
- {
- ifconstexpr (SDL_ALPHA_OPAQUE != 255)
- {
- hasAlpha = true;
- memset(alphaChannel, SDL_ALPHA_OPAQUE, sz);
- }
- }
- }
- else
- {
- ifconstexpr (SDL_ALPHA_OPAQUE != 255)
- {
- hasAlpha = true;
- memset(alphaChannel, SDL_ALPHA_OPAQUE, sz);
- }
- }
-
- SDL_Surface *image;
-
- // Convert the surface to the current display format
- if (hasAlpha)
- {
- image = MSDL_DisplayFormatAlpha(tmpImage);
- }
- else
- {
- image = MSDL_DisplayFormat(tmpImage);
-
- // We also delete the alpha channel since
- // it's not used.
- delete [] alphaChannel;
- alphaChannel = nullptr;
- }
-
- if (image == nullptr)
- {
- reportAlways("Error: Image convert failed.");
- delete [] alphaChannel;
- return nullptr;
- }
-
- if (converted)
- MSDL_FreeSurface(tmpImage);
- return new Image(image, hasAlpha, alphaChannel);
-}
-
-int SDLImageHelper::combineSurface(SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- SDL_Surface *restrict const dst,
- SDL_Rect *restrict const dstrect)
-{
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
- return SDLgfxBlitRGBA(src, srcrect, dst, dstrect);
-#else // SDL_BYTEORDER == SDL_LIL_ENDIAN
-
- return SDL_gfxBlitRGBA(src, srcrect, dst, dstrect);
-#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
-}
-
-void SDLImageHelper::copySurfaceToImage(const Image *const image,
- const int x, const int y,
- SDL_Surface *const surface) const
-{
- if ((image == nullptr) || (surface == nullptr))
- return;
-
- SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);
- SDL_Rect rect =
- {
- CAST_S16(x), CAST_S16(y),
- CAST_U16(surface->w), static_cast<uint16_t>(surface->h)
- };
-
- SDL_BlitSurface(surface, nullptr, image->mSDLSurface, &rect);
-}
-
-#endif // USE_SDL2
diff --git a/src/resources/sdlimagehelper.h b/src/resources/sdlimagehelper.h
deleted file mode 100644
index e528492d5..000000000
--- a/src/resources/sdlimagehelper.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SDLIMAGEHELPER_H
-#define RESOURCES_SDLIMAGEHELPER_H
-
-#ifdef USE_SDL2
-#include "resources/sdl2imagehelper.h"
-RESOURCES_SDL2IMAGEHELPER_H
-
-#else
-
-#include "localconsts.h"
-
-#include "resources/imagehelper.h"
-
-class Dye;
-class Image;
-
-/**
- * Defines a class for loading and storing images.
- */
-class SDLImageHelper final : public ImageHelper
-{
- friend class Image;
-
- public:
- SDLImageHelper() :
- ImageHelper()
- { }
-
- A_DELETE_COPY(SDLImageHelper)
-
- ~SDLImageHelper()
- { }
-
- /**
- * Loads an image from an SDL_RWops structure and recolors it.
- *
- * @param rw The SDL_RWops to load the image from.
- * @param dye The dye used to recolor the image.
- *
- * @return <code>NULL</code> if an error occurred, a valid pointer
- * otherwise.
- */
- Image *load(SDL_RWops *const rw,
- Dye const &dye) override final A_WARN_UNUSED;
-
- /**
- * Loads an image from an SDL surface.
- */
- Image *loadSurface(SDL_Surface *const tmpImage) override final
- A_WARN_UNUSED;
-
- Image *createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- const float alpha)
- override final A_WARN_UNUSED;
-
- void copySurfaceToImage(const Image *const image,
- const int x, const int y,
- SDL_Surface *const surface)
- const override final;
-
- constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2
- { mEnableAlphaCache = n; }
-
- static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
- { return mEnableAlphaCache; }
-
- static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
- A_WARN_UNUSED;
-
- static int combineSurface(SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- SDL_Surface *restrict const dst,
- SDL_Rect *restrict const dstrect);
-
- protected:
- /** SDL_Surface to SDL_Surface Image loader */
- Image *_SDLload(SDL_Surface *tmpImage) A_WARN_UNUSED;
-
- static bool mEnableAlphaCache;
-};
-
-#endif // USE_SDL2
-#endif // RESOURCES_SDLIMAGEHELPER_H
diff --git a/src/resources/sdlmusic.cpp b/src/resources/sdlmusic.cpp
deleted file mode 100644
index be363fc48..000000000
--- a/src/resources/sdlmusic.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/sdlmusic.h"
-
-#include "debug.h"
-
-#ifndef USE_SDL2
-#define SDL_MIXER_COMPILEDVERSION \
- SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, \
- SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL)
-
-#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
- (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
-#endif // USE_SDL2
-
-SDLMusic::SDLMusic(Mix_Music *const music,
- SDL_RWops *const rw,
- const std::string &name) :
- Resource(),
- mName(name),
- mMusic(music),
- mRw(rw)
-{
-}
-
-SDLMusic::~SDLMusic()
-{
- Mix_FreeMusic(mMusic);
-#ifndef USE_SDL2
-#if SDL_MIXER_VERSION_ATLEAST(1, 2, 12)
- if (mRw != nullptr)
- {
- SDL_RWclose(mRw);
- mRw = nullptr;
- }
-#endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 12)
-#endif // USE_SDL2
-}
-
-bool SDLMusic::play(const int loops,
- const int fadeIn) const
-{
- if (fadeIn > 0)
- return Mix_FadeInMusicPos(mMusic, loops, fadeIn, 0.0) != 0;
- return Mix_FadeInMusicPos(mMusic, loops, 0, 0.0) != 0;
-}
-
-int SDLMusic::calcMemoryLocal() const
-{
- // +++ not used size of SDL_RWops
- return static_cast<int>(sizeof(SDLMusic)) +
- Resource::calcMemoryLocal();
-}
diff --git a/src/resources/sdlmusic.h b/src/resources/sdlmusic.h
deleted file mode 100644
index 70614c420..000000000
--- a/src/resources/sdlmusic.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SDLMUSIC_H
-#define RESOURCES_SDLMUSIC_H
-
-#include "resources/resource.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_mixer.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "localconsts.h"
-
-/**
- * Defines a class for loading and storing music.
- */
-class SDLMusic final : public Resource
-{
- public:
- SDLMusic() :
- Resource(),
- mName(),
- mMusic(nullptr),
- mRw(nullptr)
- { }
-
- SDLMusic(Mix_Music *const music,
- SDL_RWops *const rw,
- const std::string &name);
-
- A_DELETE_COPY(SDLMusic)
-
- /**
- * Destructor.
- */
- ~SDLMusic();
-
- /**
- * Plays the music.
- *
- * @param loops Number of times to repeat the playback (-1 means
- * forever).
- * @param fadeIn Duration in milliseconds to fade in the music.
- *
- * @return <code>true</code> if the playback started properly
- * <code>false</code> otherwise.
- */
- bool play(const int loops = -1,
- const int fadeIn = 0) const;
-
- int calcMemoryLocal() const override final;
-
- std::string getCounterName() const override final
- { return mName; }
-
- protected:
- std::string mName;
- Mix_Music *mMusic;
- SDL_RWops *mRw;
-};
-
-#endif // RESOURCES_SDLMUSIC_H
diff --git a/src/resources/sdlscreenshothelper.cpp b/src/resources/sdlscreenshothelper.cpp
deleted file mode 100644
index d707b7dc7..000000000
--- a/src/resources/sdlscreenshothelper.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/sdlscreenshothelper.h"
-
-#include "render/graphics.h"
-
-#include "utils/sdlcheckutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-SdlScreenshotHelper::SdlScreenshotHelper() :
- ScreenshotHelper()
-{
-}
-
-SdlScreenshotHelper::~SdlScreenshotHelper()
-{
-}
-
-void SdlScreenshotHelper::prepare()
-{
-}
-
-SDL_Surface *SdlScreenshotHelper::getScreenshot()
-{
- if (mainGraphics == nullptr)
- return nullptr;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int amask = 0x00000000;
-
- SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
- mainGraphics->mWidth, mainGraphics->mHeight,
- 24,
- rmask, gmask, bmask, amask);
-
-#ifndef USE_SDL2
- if (screenshot != nullptr)
- SDL_BlitSurface(mainGraphics->mWindow, nullptr, screenshot, nullptr);
-#endif // USE_SDL2
-
- return screenshot;
-}
diff --git a/src/resources/sdlscreenshothelper.h b/src/resources/sdlscreenshothelper.h
deleted file mode 100644
index fad0a61d5..000000000
--- a/src/resources/sdlscreenshothelper.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SDLSCREENSHOTHELPER_H
-#define RESOURCES_SDLSCREENSHOTHELPER_H
-
-#include "resources/screenshothelper.h"
-
-#include "localconsts.h"
-
-class SdlScreenshotHelper final : public ScreenshotHelper
-{
- public:
- SdlScreenshotHelper();
-
- A_DELETE_COPY(SdlScreenshotHelper)
-
- ~SdlScreenshotHelper();
-
- void prepare() override final A_CONST;
-
- SDL_Surface *getScreenshot() override final;
-};
-
-#endif // RESOURCES_SDLSCREENSHOTHELPER_H
diff --git a/src/resources/servercommands.inc b/src/resources/servercommands.inc
deleted file mode 100644
index 01825fda6..000000000
--- a/src/resources/servercommands.inc
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define SERVERCOMMANDS_VOID
-
-// Hercules commands
-servercommandFirst(warp)
-servercommand(where)
-servercommand(jumpto)
-servercommand(jump)
-servercommand(who)
-servercommand(who2)
-servercommand(who3)
-servercommand(whomap)
-servercommand(whomap2)
-servercommand(whomap3)
-servercommand(whogm)
-servercommand(save)
-servercommand(load)
-servercommand(speed)
-servercommand(storage)
-servercommand(guildstorage)
-servercommand(option)
-servercommand(hide)
-servercommand(jobchange)
-servercommand(kill)
-servercommand(alive)
-servercommand(kami)
-servercommand(kamib)
-servercommand(kamic)
-servercommand(lkami)
-servercommand(heal)
-servercommand(item)
-servercommand(item2)
-servercommand(itembound)
-servercommand(itembound2)
-servercommand(itemreset)
-servercommand(clearstorage)
-servercommand(cleargstorage)
-servercommand(clearcart)
-servercommand(blvl)
-servercommand(jlvl)
-servercommand(help)
-servercommand(pvpoff)
-servercommand(pvpon)
-servercommand(gvgoff)
-servercommand(gvgon)
-servercommand(model)
-servercommand(go)
-servercommand(monster)
-servercommand(monstersmall)
-servercommand(monsterbig)
-servercommand(killmonster)
-servercommand(killmonster2)
-servercommand(refine)
-servercommand(produce)
-servercommand(memo)
-servercommand(gat)
-servercommand(displaystatus)
-servercommand(stpoint)
-servercommand(skpoint)
-servercommand(zeny)
-servercommand(str)
-servercommand(agi)
-servercommand(vit)
-servercommand2(int_, int)
-servercommand(dex)
-servercommand(luk)
-servercommand(glvl)
-servercommand(makeegg)
-servercommand(hatch)
-servercommand(petfriendly)
-servercommand(pethungry)
-servercommand(petrename)
-servercommand(recall)
-servercommand(night)
-servercommand(day)
-servercommand(doom)
-servercommand(doommap)
-servercommand(raise)
-servercommand(raisemap)
-servercommand(kick)
-servercommand(kickall)
-servercommand(allskill)
-servercommand(questskill)
-servercommand(lostskill)
-servercommand(spiritball)
-servercommand(party)
-servercommand(guild)
-servercommand(breakguild)
-servercommand(agitstart)
-servercommand(agitend)
-servercommand(mapexit)
-servercommand(idsearch)
-servercommand(broadcast)
-servercommand(localbroadcast)
-servercommand(recallall)
-servercommand(reloaditemdb)
-servercommand(reloadmobdb)
-servercommand(reloadskilldb)
-servercommand(reloadscript)
-servercommand(reloadatcommand)
-servercommand(reloadbattleconf)
-servercommand(reloadstatusdb)
-servercommand(reloadpcdb)
-servercommand(mapinfo)
-servercommand(dye)
-servercommand(hairstyle)
-servercommand(haircolor)
-servercommand(allstats)
-servercommand(block)
-servercommand(ban)
-servercommand(charban)
-servercommand(unblock)
-servercommand(charunban)
-servercommand(unban)
-servercommand(mount)
-servercommand(guildspy)
-servercommand(partyspy)
-servercommand(repairall)
-servercommand(guildrecall)
-servercommand(partyrecall)
-servercommand(nuke)
-servercommand(shownpc)
-servercommand(hidenpc)
-servercommand(loadnpc)
-servercommand(unloadnpc)
-servercommand(time)
-servercommand(jail)
-servercommand(unjail)
-servercommand(jailfor)
-servercommand(jailtime)
-servercommand(disguise)
-servercommand(undisguise)
-servercommand(email)
-servercommand(effect)
-servercommand(follow)
-servercommand(addwarp)
-servercommand(skillon)
-servercommand(skilloff)
-servercommand(killer)
-servercommand(npcmove)
-servercommand(killable)
-servercommand(dropall)
-servercommand(storeall)
-servercommand(skillid)
-servercommand(useskill)
-servercommand(displayskill)
-servercommand(snow)
-servercommand(sakura)
-servercommand(clouds)
-servercommand(clouds2)
-servercommand(fog)
-servercommand(fireworks)
-servercommand(leaves)
-servercommand(summon)
-servercommand(adjgroup)
-servercommand(trade)
-servercommand(send)
-servercommand(setbattleflag)
-servercommand(unmute)
-servercommand(clearweather)
-servercommand(uptime)
-servercommand(changesex)
-servercommand(mute)
-servercommand(refresh)
-servercommand(refreshall)
-servercommand(identify)
-servercommand(misceffect)
-servercommand(mobsearch)
-servercommand(cleanmap)
-servercommand(cleanarea)
-servercommand(npctalk)
-servercommand(pettalk)
-servercommand(users)
-servercommand(reset)
-servercommand(skilltree)
-servercommand(marry)
-servercommand(divorce)
-servercommand(sound)
-servercommand(undisguiseall)
-servercommand(disguiseall)
-servercommand(changelook)
-servercommand(autoloot)
-servercommand(alootid)
-servercommand(autoloottype)
-servercommand(mobinfo)
-servercommand(exp)
-servercommand(version)
-servercommand(mutearea)
-servercommand(rates)
-servercommand(iteminfo)
-servercommand(whodrops)
-servercommand(whereis)
-servercommand(mapflag)
-servercommand(me)
-servercommand(monsterignore)
-servercommand(fakename)
-servercommand(size)
-servercommand(showexp)
-servercommand(showzeny)
-servercommand(showdelay)
-servercommand(autotrade)
-servercommand(changegm)
-servercommand(changeleader)
-servercommand(partyoption)
-servercommand(invite)
-servercommand(duel)
-servercommand(leave)
-servercommand(accept)
-servercommand(reject)
-servercommand(clone)
-servercommand(slaveclone)
-servercommand(evilclone)
-servercommand(tonpc)
-servercommand(commands)
-servercommand(noask)
-servercommand(request)
-servercommand(homlevel)
-servercommand(homevolution)
-servercommand(hommutate)
-servercommand(makehomun)
-servercommand(homfriendly)
-servercommand(homhungry)
-servercommand(homtalk)
-servercommand(hominfo)
-servercommand(homstats)
-servercommand(homshuffle)
-servercommand(showmobs)
-servercommand(feelreset)
-servercommand(auction)
-servercommand(mail)
-servercommand(noks)
-servercommand(allowks)
-servercommand(cash)
-servercommand(points)
-servercommand(agitstart2)
-servercommand(agitend2)
-servercommand(skreset)
-servercommand(streset)
-servercommand(storagelist)
-servercommand(cartlist)
-servercommand(itemlist)
-servercommand(stats)
-servercommand(delitem)
-servercommand(charcommands)
-servercommand(font)
-servercommand(accinfo)
-servercommand(set)
-servercommand(reloadquestdb)
-servercommand(undisguiseguild)
-servercommand(disguiseguild)
-servercommand(sizeall)
-servercommand(sizeguild)
-servercommand(addperm)
-servercommand(rmvperm)
-servercommand(unloadnpcfile)
-servercommand(cart)
-servercommand(cashmount)
-servercommand(join)
-servercommand(channel)
-servercommand(fontcolor)
-servercommand(searchstore)
-servercommand(costume)
-servercommand(skdebug)
-servercommand(cddebug)
-servercommand(lang)
-servercommand(bodystyle)
-servercommand(setskill)
-
-// Evol commands
-servercommand(slide)
-servercommand(serverexit)
diff --git a/src/resources/serverpermissions.inc b/src/resources/serverpermissions.inc
deleted file mode 100644
index 377c3ab98..000000000
--- a/src/resources/serverpermissions.inc
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define SERVERPERMISSION_VOID
-
-// Hercules permissions
-serverpermissionFirst(can_trade)
-serverpermission(can_party)
-serverpermission(all_skill)
-serverpermission(all_equipment)
-serverpermission(skill_unconditional)
-serverpermission(join_chat)
-serverpermission(kick_chat)
-serverpermission(hide_session)
-serverpermission(who_display_aid)
-serverpermission(hack_info)
-serverpermission(any_warp)
-serverpermission(view_hpmeter)
-serverpermission(view_equipment)
-serverpermission(use_check)
-serverpermission(use_changemaptype)
-serverpermission(all_commands)
-serverpermission(receive_requests)
-serverpermission(show_bossmobs)
-serverpermission(disable_pvm)
-serverpermission(disable_pvp)
-serverpermission(disable_commands_when_dead)
-serverpermission(hchsys_admin)
-serverpermission(can_trade_bound)
-serverpermission(disable_pickup)
-serverpermission(disable_store)
-serverpermission(disable_exp)
-serverpermission(disable_skill_usage)
-
-// Evol permissions
-serverpermission(send_gm)
-serverpermission(show_client_version)
diff --git a/src/resources/skill/skilldata.cpp b/src/resources/skill/skilldata.cpp
deleted file mode 100644
index ef3b331cf..000000000
--- a/src/resources/skill/skilldata.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/skill/skilldata.h"
-
-#include "configuration.h"
-
-#include "gui/theme.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "debug.h"
-
-SkillData::SkillData() :
- name(),
- shortName(),
- dispName(),
- description(),
- missile(),
- castingMissile(),
- invokeCmd(),
- castingAnimation(),
- soundHit(std::string(), 0),
- soundMiss(std::string(), 0),
- icon(nullptr),
- updateEffectId(-1),
- removeEffectId(-1),
- hitEffectId(-1),
- missEffectId(-1),
- castingSrcEffectId(-1),
- castingDstEffectId(-1),
- castingGroundEffectId(-1),
- srcEffectId(-1),
- dstEffectId(-1),
- haveIcon(false),
- autoTab(true)
-{
-}
-
-SkillData::~SkillData()
-{
- if (icon != nullptr)
- {
- icon->decRef();
- icon = nullptr;
- }
-}
-
-void SkillData::setIcon(const std::string &iconPath)
-{
- if (!iconPath.empty())
- icon = Loader::getImage(iconPath);
-
- if (icon == nullptr)
- {
- icon = Theme::getImageFromTheme(
- paths.getStringValue("unknownItemFile"));
- }
-}
diff --git a/src/resources/skill/skilldata.h b/src/resources/skill/skilldata.h
deleted file mode 100644
index 7dc2e05ac..000000000
--- a/src/resources/skill/skilldata.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUI_WIDGETS_SKILLDATA_H
-#define GUI_WIDGETS_SKILLDATA_H
-
-#include "resources/missileinfo.h"
-#include "resources/soundinfo.h"
-
-class Image;
-
-struct SkillData final
-{
- std::string name;
- std::string shortName;
- std::string dispName;
- std::string description;
-
- MissileInfo missile;
- MissileInfo castingMissile;
- std::string invokeCmd;
- std::string castingAnimation;
-
- SoundInfo soundHit;
- SoundInfo soundMiss;
-
- Image *icon;
-
- int updateEffectId;
- int removeEffectId;
- int hitEffectId;
- int missEffectId;
- int castingSrcEffectId;
- int castingDstEffectId;
- int castingGroundEffectId;
- int srcEffectId;
- int dstEffectId;
- bool haveIcon;
- bool autoTab;
-
- SkillData();
- A_DELETE_COPY(SkillData)
- ~SkillData();
-
- void setIcon(const std::string &iconPath);
-};
-
-#endif // GUI_WIDGETS_SKILLDATA_H
diff --git a/src/resources/skill/skillinfo.cpp b/src/resources/skill/skillinfo.cpp
deleted file mode 100644
index 3f6a50eb6..000000000
--- a/src/resources/skill/skillinfo.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/skill/skillinfo.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/models/skillmodel.h"
-
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include "resources/skill/skilldata.h"
-#include "resources/skill/skilltypelist.h"
-
-#include "debug.h"
-
-SkillInfo::SkillInfo() :
- skillLevel(),
- skillEffect(),
- useButton(),
- errorText(),
- castingAction(),
- castingRideAction(),
- castingSkyAction(),
- castingWaterAction(),
- dataMap(),
- model(nullptr),
- tab(nullptr),
- data(nullptr),
- level(0),
- customSelectedLevel(0),
- customOffsetX(0),
- customOffsetY(0),
- skillLevelWidth(0),
- id(0),
- range(0),
- sp(0),
- duration(0),
- durationTime(0),
- cooldown(0),
- x(0),
- y(0),
- type(SkillType::Unknown),
- owner(SkillOwner::Player),
- customCastType(CastType::Default),
- modifiable(Modifiable_false),
- visible(Visible_false),
- alwaysVisible(Visible_false),
- useTextParameter(false)
-{
- dataMap[0] = new SkillData;
- data = dataMap[0];
-}
-
-SkillInfo::~SkillInfo()
-{
- FOR_EACH (SkillDataMapIter, it, dataMap)
- delete (*it).second;
- dataMap.clear();
-}
-
-void SkillInfo::update()
-{
- const int baseLevel = PlayerInfo::getSkillLevel(id);
- if (modifiable == Modifiable_false && baseLevel == 0)
- {
- if (visible == Visible_true)
- {
- visible = Visible_false;
- if (model != nullptr)
- model->updateVisibilities();
- }
- return;
- }
-
- const bool updateVisibility = (visible == Visible_false);
- visible = Visible_true;
-
- if (baseLevel == 0)
- {
- skillLevel.clear();
- }
- else
- {
- if (customSelectedLevel == 0)
- {
- // TRANSLATORS: skill level
- skillLevel = strprintf(_("Lvl: %d"), baseLevel);
- }
- else
- {
- // TRANSLATORS: skill level
- skillLevel = strprintf(_("Lvl: %d / %d"),
- customSelectedLevel,
- baseLevel);
- }
- }
-
- // TRANSLATORS: skill type
- const char *const typeStr = _("Type: %s");
-
- if (type == SkillType::Unknown)
- {
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Unknown"));
- }
- else
- {
- skillEffect.clear();
- for (size_t f = 0; f < skillTypeListSize; f ++)
- {
- const SkillTypeEntry &item = skillTypeList[f];
- if ((item.type & type) != 0)
- {
- if (!skillEffect.empty())
- skillEffect.append(", ");
- skillEffect.append(strprintf(typeStr, item.name));
- }
- }
- }
- if (skillEffect.empty())
- {
- // TRANSLATORS: Skill type
- skillEffect = strprintf(typeStr, _("Unknown:"));
- skillEffect.append(" ").append(toString(CAST_S32(type)));
- }
-
- if (sp != 0)
- {
- // TRANSLATORS: skill mana
- skillEffect.append(strprintf(_(" / Mana: -%d"), sp));
- }
-
- if (range > 0)
- {
- if (!skillEffect.empty())
- skillEffect.append(" / ");
- // TRANSLATORS: skill range
- skillEffect.append(strprintf(_("Range: %d"), range));
- }
-
- level = baseLevel;
- if (customSelectedLevel > level)
- customSelectedLevel = level;
-
- skillLevelWidth = -1;
-
- if (updateVisibility && (model != nullptr))
- model->updateVisibilities();
-
- data = getData(level);
- if (data == nullptr)
- data = dataMap[0];
-}
-
-
-void SkillInfo::addData(const int level1, SkillData *const data1)
-{
- dataMap[level1] = data1;
-}
-
-SkillData *SkillInfo::getData(const int level1) const
-{
- const SkillDataMapCIter it = dataMap.find(level1);
- if (it == dataMap.end())
- return nullptr;
- return (*it).second;
-}
-
-SkillData *SkillInfo::getData1(const int lev) const
-{
- const SkillDataMapCIter it = dataMap.find(lev);
- if (it == dataMap.end())
- return (*dataMap.begin()).second;
- return (*it).second;
-}
-
-std::string SkillInfo::toDataStr() const
-{
- return strprintf("%d %d %d",
- CAST_S32(customCastType),
- customOffsetX,
- customOffsetY);
-}
diff --git a/src/resources/skill/skillinfo.h b/src/resources/skill/skillinfo.h
deleted file mode 100644
index c07b3209f..000000000
--- a/src/resources/skill/skillinfo.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUI_WIDGETS_SKILLINFO_H
-#define GUI_WIDGETS_SKILLINFO_H
-
-#include "enums/simpletypes/modifiable.h"
-#include "enums/simpletypes/visible.h"
-
-#include "enums/resources/skill/casttype.h"
-#include "enums/resources/skill/skillowner.h"
-#include "enums/resources/skill/skilltype.h"
-
-#include "utils/vector.h"
-
-#include <string>
-#include <map>
-
-#include "localconsts.h"
-
-struct SkillData;
-
-class SkillModel;
-class SkillTab;
-
-typedef std::map<int, SkillData*> SkillDataMap;
-typedef SkillDataMap::iterator SkillDataMapIter;
-typedef SkillDataMap::const_iterator SkillDataMapCIter;
-
-struct SkillInfo final
-{
- std::string skillLevel;
- std::string skillEffect;
- std::string useButton;
- std::string errorText;
- std::string castingAction;
- std::string castingRideAction;
- std::string castingSkyAction;
- std::string castingWaterAction;
- SkillDataMap dataMap;
- SkillModel *model;
- SkillTab *tab;
- SkillData *data;
- int level;
- int customSelectedLevel;
- int customOffsetX;
- int customOffsetY;
- int skillLevelWidth;
- unsigned int id;
- int range;
- int sp;
- int duration;
- int durationTime;
- int cooldown;
- int x;
- int y;
- SkillType::SkillType type;
- SkillOwner::Type owner;
- CastTypeT customCastType;
- Modifiable modifiable;
- Visible visible;
- Visible alwaysVisible;
- bool useTextParameter;
-
- SkillInfo();
- A_DELETE_COPY(SkillInfo)
- ~SkillInfo();
-
- void update();
-
- SkillData *getData(const int level) const A_WARN_UNUSED;
- SkillData *getData1(const int level) const A_WARN_UNUSED;
-
- void addData(const int level, SkillData *const data);
-
- bool isUsable() const noexcept2 A_WARN_UNUSED
- {
- return type == SkillType::Attack
- || type == SkillType::Self
- || type == SkillType::Support;
- }
-
- std::string toDataStr() const A_WARN_UNUSED;
-};
-
-typedef STD_VECTOR<SkillInfo*> SkillList;
-typedef SkillList::iterator SkillListIter;
-
-#endif // GUI_WIDGETS_SKILLINFO_H
diff --git a/src/resources/skill/skilltypeentry.h b/src/resources/skill/skilltypeentry.h
deleted file mode 100644
index fdb1604fe..000000000
--- a/src/resources/skill/skilltypeentry.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SKILLTYPEENTRY_H
-#define RESOURCES_SKILLTYPEENTRY_H
-
-#include "enums/resources/skill/skilltype.h"
-
-#include "localconsts.h"
-
-struct SkillTypeEntry final
-{
- A_DEFAULT_COPY(SkillTypeEntry)
-
- const SkillType::SkillType type;
- const char *const name;
-};
-
-#endif // RESOURCES_SKILLTYPEENTRY_H
diff --git a/src/resources/skill/skilltypelist.h b/src/resources/skill/skilltypelist.h
deleted file mode 100644
index 667d90e2c..000000000
--- a/src/resources/skill/skilltypelist.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SKILLTYPELIST_H
-#define RESOURCES_SKILLTYPELIST_H
-
-#include "utils/gettext.h"
-
-#include "resources/skill/skilltypeentry.h"
-
-#include "localconsts.h"
-
-const size_t skillTypeListSize = 6;
-
-SkillTypeEntry skillTypeList[skillTypeListSize] =
-{
- // TRANSLATORS: Skill type
- { SkillType::Attack, N_("Attack") },
- // TRANSLATORS: Skill type
- { SkillType::Ground, N_("Ground") },
- // TRANSLATORS: Skill type
- { SkillType::Self, N_("Self") },
- // TRANSLATORS: Skill type
- { SkillType::Unused, N_("Unused") },
- // TRANSLATORS: Skill type
- { SkillType::Support, N_("Support") },
- // TRANSLATORS: Skill type
- { SkillType::TargetTrap, N_("TargetTrap") }
-};
-
-#endif // RESOURCES_SKILLTYPELIST_H
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp
deleted file mode 100644
index db7c5d462..000000000
--- a/src/resources/soundeffect.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/soundeffect.h"
-
-#include "debug.h"
-
-SoundEffect::~SoundEffect()
-{
- Mix_FreeChunk(mChunk);
-}
-
-bool SoundEffect::play(const int loops, const int volume,
- const int channel) const
-{
- Mix_VolumeChunk(mChunk, volume);
-
- return Mix_PlayChannel(channel, mChunk, loops) != -1;
-}
-
-int SoundEffect::calcMemoryLocal() const
-{
- return static_cast<int>(sizeof(SoundEffect) +
- sizeof(SDL_AudioSpec)) +
- Resource::calcMemoryLocal();
-}
diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h
deleted file mode 100644
index 2797ce00e..000000000
--- a/src/resources/soundeffect.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SOUNDEFFECT_H
-#define RESOURCES_SOUNDEFFECT_H
-
-#include "resources/resource.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_mixer.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "localconsts.h"
-
-/**
- * Defines a class for loading and storing sound effects.
- */
-class SoundEffect final : public Resource
-{
- public:
- /**
- * Constructor.
- */
- SoundEffect(Mix_Chunk *const soundEffect,
- const std::string &name) :
- Resource(),
- mName(name),
- mChunk(soundEffect)
- { }
-
- A_DELETE_COPY(SoundEffect)
-
- /**
- * Destructor.
- */
- ~SoundEffect();
-
- /**
- * Plays the sample.
- *
- * @param loops Number of times to repeat the playback.
- * @param volume Sample playback volume.
- * @param channel Sample playback channel.
- *
- * @return <code>true</code> if the playback started properly
- * <code>false</code> otherwise.
- */
- bool play(const int loops, const int volume,
- const int channel = -1) const;
-
- int calcMemoryLocal() const override final;
-
- std::string getCounterName() const override final
- { return mName; }
-
- protected:
- std::string mName;
- Mix_Chunk *mChunk;
-};
-
-#endif // RESOURCES_SOUNDEFFECT_H
diff --git a/src/resources/soundinfo.h b/src/resources/soundinfo.h
deleted file mode 100644
index 82b4138de..000000000
--- a/src/resources/soundinfo.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SOUNDINFO_H
-#define RESOURCES_SOUNDINFO_H
-
-#include "enums/resources/item/itemsoundevent.h"
-
-#include "utils/vector.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-struct SoundInfo final
-{
- SoundInfo(const std::string &sound0,
- const int delay0) :
- sound(sound0),
- delay(delay0)
- {
- }
-
- A_DEFAULT_COPY(SoundInfo)
-
- std::string sound;
- int delay;
-};
-
-typedef STD_VECTOR<SoundInfo> SoundInfoVect;
-typedef std::map<ItemSoundEvent::Type, SoundInfoVect*> ItemSoundEvents;
-
-#endif // RESOURCES_SOUNDINFO_H
diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp
deleted file mode 100644
index 9d7186335..000000000
--- a/src/resources/sprite/animatedsprite.cpp
+++ /dev/null
@@ -1,485 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "render/graphics.h"
-
-#include "resources/action.h"
-#include "resources/delayedmanager.h"
-
-#include "resources/animation/animation.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/spritedefloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sprite/animationdelayload.h"
-
-#include "utils/delete2.h"
-#include "utils/likely.h"
-#include "utils/mrand.h"
-
-#include "debug.h"
-
-bool AnimatedSprite::mEnableCache = false;
-
-AnimatedSprite::AnimatedSprite(SpriteDef *restrict const sprite) :
- mDirection(SpriteDirection::DOWN),
- mLastTime(0),
- mFrameIndex(0),
- mFrameTime(0),
- mSprite(sprite),
- mAction(nullptr),
- mAnimation(nullptr),
- mFrame(nullptr),
- mNumber(100),
- mNumber1(100),
- mDelayLoad(nullptr),
- mTerminated(false)
-{
- mAlpha = 1.0F;
-
- // Take possession of the sprite
- if (mSprite != nullptr)
- mSprite->incRef();
-}
-
-AnimatedSprite *AnimatedSprite::load(const std::string &restrict filename,
- const int variant)
-{
- SpriteDef *restrict const s = Loader::getSprite(
- filename, variant);
- if (s == nullptr)
- return nullptr;
- AnimatedSprite *restrict const as = new AnimatedSprite(s);
-#ifdef DEBUG_ANIMATIONS
- as->setSpriteName(filename);
-#endif // DEBUG_ANIMATIONS
-
- as->play(SpriteAction::STAND);
- s->decRef();
- return as;
-}
-
-AnimatedSprite *AnimatedSprite::delayedLoad(const std::string &restrict
- filename,
- const int variant)
-{
- if (!mEnableCache)
- return load(filename, variant);
- Resource *restrict const res = ResourceManager::getFromCache(
- filename, variant);
- if (res != nullptr)
- {
- res->decRef();
- return load(filename, variant);
- }
-
- AnimatedSprite *restrict const as = new AnimatedSprite(nullptr);
-#ifdef DEBUG_ANIMATIONS
- as->setSpriteName(filename);
-#endif // DEBUG_ANIMATIONS
-
- as->play(SpriteAction::STAND);
- as->setDelayLoad(filename, variant);
- return as;
-}
-
-AnimatedSprite *AnimatedSprite::clone(const AnimatedSprite *restrict const
- anim)
-{
- if (anim == nullptr)
- return nullptr;
- AnimatedSprite *restrict const sprite = new AnimatedSprite(anim->mSprite);
-#ifdef DEBUG_ANIMATIONS
- sprite->setSpriteName(anim->getSpriteName());
-#endif // DEBUG_ANIMATIONS
-
- sprite->play(SpriteAction::STAND);
- return sprite;
-}
-
-AnimatedSprite::~AnimatedSprite()
-{
- if (mSprite != nullptr)
- {
- mSprite->decRef();
- mSprite = nullptr;
- }
- if (mDelayLoad != nullptr)
- {
- mDelayLoad->clearSprite();
- DelayedManager::removeDelayLoad(mDelayLoad);
- delete2(mDelayLoad);
- }
-}
-
-bool AnimatedSprite::reset() restrict2
-{
- const bool ret = mFrameIndex !=0 ||
- mFrameTime != 0 ||
- mLastTime != 0;
-
- mFrameIndex = 0;
- mFrameTime = 0;
- mLastTime = 0;
-
- if (mAnimation != nullptr)
- mFrame = &mAnimation->mFrames[0];
- else
- mFrame = nullptr;
- return ret;
-}
-
-bool AnimatedSprite::play(const std::string &restrict spriteAction) restrict2
-{
- if (mSprite == nullptr)
- {
- if (mDelayLoad == nullptr)
- return false;
- mDelayLoad->setAction(spriteAction);
- return true;
- }
-
- const Action *const action = mSprite->getAction(spriteAction, mNumber);
- if (action == nullptr)
- return false;
-
- mAction = action;
- const Animation *const animation = mAction->getAnimation(mDirection);
-
- if ((animation != nullptr) &&
- animation != mAnimation &&
- animation->getLength() > 0)
- {
- mAnimation = animation;
- reset();
-
- return true;
- }
-
- return false;
-}
-
-bool AnimatedSprite::update(const int time) restrict2
-{
- // Avoid freaking out at first frame or when tick_time overflows
- if (A_UNLIKELY(time < mLastTime || mLastTime == 0))
- mLastTime = time;
-
- // If not enough time has passed yet, do nothing
- if (time <= mLastTime || (mAnimation == nullptr))
- return false;
-
- const unsigned int dt = time - mLastTime;
- mLastTime = time;
-
- const Animation *restrict const animation = mAnimation;
- const Frame *restrict const frame = mFrame;
-
- if (A_UNLIKELY(!updateCurrentAnimation(dt)))
- {
- // Animation finished, reset to default
- play(SpriteAction::STAND);
- mTerminated = true;
- }
-
- // Make sure something actually changed
- return animation != mAnimation || frame != mFrame;
-}
-
-bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
-{
- // move code from Animation::isTerminator(*mFrame)
- if (mFrame == nullptr ||
- mAnimation == nullptr ||
- (mFrame->image == nullptr && mFrame->type == FrameType::ANIMATION))
- {
- return false;
- }
-
- mFrameTime += time;
-
- while ((mFrameTime > CAST_U32(mFrame->delay) &&
- mFrame->delay > 0) ||
- (mFrame->type != FrameType::ANIMATION &&
- mFrame->type != FrameType::PAUSE))
- {
- bool fail(true);
- mFrameTime -= CAST_U32(mFrame->delay);
- mFrameIndex++;
-
- if (mFrameIndex >= CAST_U32(mAnimation->getLength()))
- mFrameIndex = 0;
-
- mFrame = &mAnimation->mFrames[mFrameIndex];
- if (mFrame->type == FrameType::LABEL &&
- !mFrame->nextAction.empty())
- {
- fail = false;
- }
- else if (mFrame->type == FrameType::GOTO &&
- !mFrame->nextAction.empty())
- {
- const int rand = mFrame->rand;
- if (rand == 100 ||
- ((rand != 0) && rand >= mrand() % 100))
- {
- for (size_t i = 0; i < mAnimation->getLength(); i ++)
- {
- const Frame *restrict const frame =
- &mAnimation->mFrames[i];
- if (frame->type == FrameType::LABEL &&
- mFrame->nextAction == frame->nextAction)
- {
- mFrameIndex = CAST_U32(i);
- if (mFrameIndex >= CAST_U32(
- mAnimation->getLength()))
- {
- mFrameIndex = 0;
- }
-
- mFrame = &mAnimation->mFrames[mFrameIndex];
-
- fail = false;
- break;
- }
- }
- }
- else
- {
- fail = false;
- }
- }
- else if (mFrame->type == FrameType::JUMP &&
- !mFrame->nextAction.empty())
- {
- const int rand = mFrame->rand;
- if (rand == 100 ||
- ((rand != 0) && rand >= mrand() % 100))
- {
- play(mFrame->nextAction);
- return true;
- }
- }
- // copy code from Animation::isTerminator(*mFrame)
- else if ((mFrame->image == nullptr) &&
- mFrame->type == FrameType::ANIMATION)
- {
- const int rand = mFrame->rand;
- if (rand == 100 ||
- ((rand != 0) && rand >= mrand() % 100))
- {
- mAnimation = nullptr;
- mFrame = nullptr;
- return false;
- }
- }
- else
- {
- const int rand = mFrame->rand;
- if (rand == 100 ||
- mFrameIndex >= CAST_U32(mAnimation->getLength()))
- {
- fail = false;
- }
- else
- {
- if ((rand != 0) && mrand() % 100 <= rand)
- fail = false;
- }
- }
- if (fail)
- {
- if (mFrame != nullptr)
- mFrameTime = mFrame->delay + 1;
- else
- mFrameTime ++;
- }
- }
- return true;
-}
-
-void AnimatedSprite::draw(Graphics *restrict const graphics,
- const int posX,
- const int posY) const restrict2
-{
- FUNC_BLOCK("AnimatedSprite::draw", 1)
- if ((mFrame == nullptr) || (mFrame->image == nullptr))
- return;
-
- Image *restrict const image = mFrame->image;
- image->setAlpha(mAlpha);
- graphics->drawImage(image,
- posX + mFrame->offsetX, posY + mFrame->offsetY);
-}
-
-void AnimatedSprite::drawRescaled(Graphics *restrict const graphics,
- const int posX,
- const int posY,
- const int dx,
- const int dy) const restrict2
-{
- if (mFrame == nullptr ||
- mFrame->image == nullptr)
- {
- return;
- }
-
- Image *restrict const image = mFrame->image;
- image->setAlpha(mAlpha);
- graphics->drawRescaledImage(image,
- posX + mFrame->offsetX,
- posY + mFrame->offsetY,
- dx,
- dy);
-}
-
-void AnimatedSprite::drawRaw(Graphics *restrict const graphics,
- const int posX,
- const int posY) const restrict2
-{
- if ((mFrame == nullptr) || (mFrame->image == nullptr))
- return;
-
- Image *restrict const image = mFrame->image;
- image->setAlpha(mAlpha);
- graphics->drawImage(image,
- posX,
- posY);
-}
-
-bool AnimatedSprite::setSpriteDirection(const SpriteDirection::Type direction)
- restrict2
-{
- if (mDirection != direction)
- {
- mDirection = direction;
-
- if (mAction == nullptr)
- return false;
-
- const Animation *restrict const animation =
- mAction->getAnimation(mDirection);
-
- if ((animation != nullptr) &&
- animation != mAnimation &&
- animation->getLength() > 0)
- {
- mAnimation = animation;
- reset();
- }
-
- return true;
- }
-
- return false;
-}
-
-unsigned int AnimatedSprite::getFrameCount() const restrict2
-{
- if (mAnimation != nullptr)
- return CAST_U32(mAnimation->getLength());
- return 0;
-}
-
-int AnimatedSprite::getWidth() const restrict2
-{
- if ((mFrame != nullptr) && (mFrame->image != nullptr))
- return mFrame->image->mBounds.w;
- return 0;
-}
-
-int AnimatedSprite::getHeight() const restrict2
-{
- if ((mFrame != nullptr) && (mFrame->image != nullptr))
- return mFrame->image->mBounds.h;
- return 0;
-}
-
-std::string AnimatedSprite::getIdPath() const restrict2
-{
- if (mSprite == nullptr)
- return "";
- return mSprite->mIdPath;
-}
-
-const Image* AnimatedSprite::getImage() const restrict2 noexcept2
-{
- return mFrame != nullptr ? mFrame->image : nullptr;
-}
-
-void AnimatedSprite::setAlpha(float alpha) restrict2
-{
- mAlpha = alpha;
-
- if (mFrame != nullptr)
- {
- Image *restrict const image = mFrame->image;
- if (image != nullptr)
- image->setAlpha(mAlpha);
- }
-}
-
-const void *AnimatedSprite::getHash() const restrict2
-{
- if (mFrame != nullptr)
- return mFrame;
- return this;
-}
-
-bool AnimatedSprite::updateNumber(const unsigned num) restrict2
-{
- if (mSprite == nullptr)
- return false;
-
- if (mNumber1 != num)
- {
- mNumber1 = num;
- mNumber = mSprite->findNumber(num);
- if (mNumber == 0u)
- {
- mNumber = 100;
- return false;
- }
- return true;
- }
- return false;
-}
-
-void AnimatedSprite::setDelayLoad(const std::string &restrict filename,
- const int variant) restrict2
-{
- if (mDelayLoad != nullptr)
- {
- mDelayLoad->clearSprite();
- DelayedManager::removeDelayLoad(mDelayLoad);
- delete mDelayLoad;
- }
- mDelayLoad = new AnimationDelayLoad(filename, variant, this);
- DelayedManager::addDelayedAnimation(mDelayLoad);
-}
diff --git a/src/resources/sprite/animatedsprite.h b/src/resources/sprite/animatedsprite.h
deleted file mode 100644
index 01a142f31..000000000
--- a/src/resources/sprite/animatedsprite.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SPRITE_ANIMATEDSPRITE_H
-#define RESOURCES_SPRITE_ANIMATEDSPRITE_H
-
-#include "resources/sprite/sprite.h"
-
-class Animation;
-class AnimationDelayLoad;
-struct Frame;
-
-/**
- * Animates a sprite by adding playback state.
- */
-class AnimatedSprite final : public Sprite
-{
- public:
- /**
- * Constructor.
- * @param sprite the sprite to animate
- */
- explicit AnimatedSprite(SpriteDef *restrict const sprite);
-
- A_DELETE_COPY(AnimatedSprite)
-
- /**
- * An helper function, which will request the sprite to animate
- * from the resource manager.
- *
- * @param filename the file of the sprite to animate
- * @param variant the sprite variant
- */
- static AnimatedSprite *load(const std::string &restrict filename,
- const int variant = 0) A_WARN_UNUSED;
-
- static AnimatedSprite *delayedLoad(const std::string &restrict
- filename,
- const int variant = 0)
- A_WARN_UNUSED;
-
- static AnimatedSprite *clone(const AnimatedSprite *restrict const
- anim);
-
- ~AnimatedSprite();
-
- bool reset() restrict2 override final;
-
- bool play(const std::string &restrict spriteAction)
- restrict2 override final;
-
- bool update(const int time) restrict2 override final;
-
- void draw(Graphics *restrict const graphics,
- const int posX,
- const int posY) const restrict2 override final A_NONNULL(2);
-
- void drawRescaled(Graphics *restrict const graphics,
- const int posX,
- const int posY,
- const int dx,
- const int dy) const restrict2 A_NONNULL(2);
-
- void drawRaw(Graphics *restrict const graphics,
- const int posX,
- const int posY) const restrict2 A_NONNULL(2);
-
- int getWidth() const restrict2 override final A_WARN_UNUSED;
-
- int getHeight() const restrict2 override final A_WARN_UNUSED;
-
- const Image* getImage() const restrict2 noexcept2 override final
- A_WARN_UNUSED;
-
- bool setSpriteDirection(const SpriteDirection::Type direction)
- restrict2 override final;
-
- int getNumberOfLayers() const restrict2 noexcept2 A_WARN_UNUSED
- { return 1; }
-
- std::string getIdPath() const restrict2 A_WARN_UNUSED;
-
- unsigned int getCurrentFrame() const restrict2 noexcept2 override final
- A_WARN_UNUSED
- { return mFrameIndex; }
-
- unsigned int getFrameCount() const
- restrict2 override final A_WARN_UNUSED;
-
- void setAlpha(float alpha) restrict2 override final;
-
- const void *getHash() const restrict2 override final A_WARN_UNUSED;
-
- bool updateNumber(const unsigned num) restrict2 override final;
-
- void clearDelayLoad() restrict2 noexcept2
- { mDelayLoad = nullptr; }
-
- void setSprite(SpriteDef *restrict const sprite) restrict2 noexcept2
- { mSprite = sprite; }
-
- bool isTerminated() const restrict2 noexcept2
- { return mTerminated; }
-
- constexpr2 static void setEnableCache(const bool b) noexcept2
- { mEnableCache = b; }
-
- void setLastTime(const int time) noexcept2
- { mLastTime = time; }
-
-#ifdef UNITTESTS
- SpriteDef *getSprite() restrict2
- { return mSprite; }
-
- const Frame *getFrame() const restrict2
- { return mFrame; }
-
- const Animation *getAnimation() const restrict2
- { return mAnimation; }
-
- unsigned int getFrameIndex() const restrict2
- { return mFrameIndex; }
-
- unsigned int getFrameTime() const restrict2
- { return mFrameTime; }
-#endif // UNITTESTS
-
-#ifdef DEBUG_ANIMATIONS
- void setSpriteName(const std::string &restrict name) noexcept2
- { mSpriteName = name; }
-
- std::string getSpriteName() const noexcept2 A_WARN_UNUSED
- { return mSpriteName; }
-#endif // DEBUG_ANIMATIONS
-
- private:
- bool updateCurrentAnimation(const unsigned int dt) restrict2;
-
- void setDelayLoad(const std::string &restrict filename,
- const int variant) restrict2;
-
-#ifdef DEBUG_ANIMATIONS
- std::string mSpriteName;
-#endif // DEBUG_ANIMATIONS
-
- SpriteDirection::Type mDirection; /**< The sprite direction. */
- int mLastTime; /**< The last time update was called. */
-
- unsigned int mFrameIndex; /**< The index of the current frame. */
- unsigned int mFrameTime; /**< The time since start of frame. */
-
- /**< The sprite definition. */
- SpriteDef *restrict mSprite;
- /**< The currently active action. */
- const Action *restrict mAction;
- /**< The currently active animation. */
- const Animation *restrict mAnimation;
- /**< The currently active frame. */
- const Frame *restrict mFrame;
- unsigned mNumber;
- unsigned mNumber1;
- AnimationDelayLoad *mDelayLoad;
- bool mTerminated;
- static bool mEnableCache;
-};
-
-#endif // RESOURCES_SPRITE_ANIMATEDSPRITE_H
diff --git a/src/resources/sprite/animationdelayload.cpp b/src/resources/sprite/animationdelayload.cpp
deleted file mode 100644
index 37222d068..000000000
--- a/src/resources/sprite/animationdelayload.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/sprite/animationdelayload.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "resources/loaders/spritedefloader.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "debug.h"
-
-AnimationDelayLoad::AnimationDelayLoad(const std::string &fileName,
- const int variant,
- AnimatedSprite *const sprite) :
- mFileName(fileName),
- mVariant(variant),
- mSprite(sprite),
- mAction(SpriteAction::STAND)
-{
-}
-
-AnimationDelayLoad::~AnimationDelayLoad()
-{
- if (mSprite != nullptr)
- {
- mSprite->clearDelayLoad();
- mSprite = nullptr;
- }
-}
-
-void AnimationDelayLoad::clearSprite()
-{
- mSprite = nullptr;
-}
-
-void AnimationDelayLoad::load()
-{
- if (mSprite != nullptr)
- {
- SpriteDef *const s = Loader::getSprite(mFileName, mVariant);
- if (s == nullptr)
- return;
- mSprite->setSprite(s);
- mSprite->play(mAction);
- }
-}
diff --git a/src/resources/sprite/animationdelayload.h b/src/resources/sprite/animationdelayload.h
deleted file mode 100644
index f559b4fb3..000000000
--- a/src/resources/sprite/animationdelayload.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SPRITE_ANIMATIONDELAYLOAD_H
-#define RESOURCES_SPRITE_ANIMATIONDELAYLOAD_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class AnimatedSprite;
-
-class AnimationDelayLoad final
-{
- public:
- AnimationDelayLoad(const std::string &fileName,
- const int variant,
- AnimatedSprite *const sprite);
-
- A_DELETE_COPY(AnimationDelayLoad)
-
- ~AnimationDelayLoad();
-
- void clearSprite();
-
- void load();
-
- void setAction(const std::string &action)
- { mAction = action; }
-
- private:
- std::string mFileName;
- int mVariant;
- AnimatedSprite *mSprite;
- std::string mAction;
-};
-
-#endif // RESOURCES_SPRITE_ANIMATIONDELAYLOAD_H
diff --git a/src/resources/sprite/imagesprite.cpp b/src/resources/sprite/imagesprite.cpp
deleted file mode 100644
index b5aace2e1..000000000
--- a/src/resources/sprite/imagesprite.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/sprite/imagesprite.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-ImageSprite::ImageSprite(Image *const image) :
- mImage(image)
-{
- if (mImage != nullptr)
- {
- mAlpha = mImage->mAlpha;
- mImage->incRef();
- }
- else
- {
- mAlpha = 1;
- }
-}
-
-ImageSprite::~ImageSprite()
-{
- if (mImage != nullptr)
- {
- mImage->decRef();
- mImage = nullptr;
- }
-}
-
-void ImageSprite::draw(Graphics *const graphics,
- const int posX, const int posY) const
-{
- FUNC_BLOCK("ImageSprite::draw", 1)
- if (mImage == nullptr)
- return;
-
- mImage->setAlpha(mAlpha);
- graphics->drawImage(mImage, posX, posY);
-}
diff --git a/src/resources/sprite/imagesprite.h b/src/resources/sprite/imagesprite.h
deleted file mode 100644
index 9576933d1..000000000
--- a/src/resources/sprite/imagesprite.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SPRITE_IMAGESPRITE_H
-#define RESOURCES_SPRITE_IMAGESPRITE_H
-
-#include "resources/sprite/sprite.h"
-
-#include "resources/image/image.h"
-
-class Graphics;
-
-class ImageSprite final : public Sprite
-{
- public:
- explicit ImageSprite(Image *const image);
-
- A_DELETE_COPY(ImageSprite)
-
- ~ImageSprite();
-
- bool reset() override final
- { return false; }
-
- bool play(const std::string &action A_UNUSED) override final
- { return false; }
-
- bool update(const int time A_UNUSED) override final
- { return false; }
-
- void draw(Graphics *const graphics,
- const int posX, const int posY)
- const override final A_NONNULL(2);
-
- int getWidth() const override final A_WARN_UNUSED
- { return mImage != nullptr ? mImage->getWidth() : 0; }
-
- int getHeight() const override final A_WARN_UNUSED
- { return mImage != nullptr ? mImage->getHeight() : 0; }
-
- const Image* getImage() const override final A_WARN_UNUSED
- { return mImage; }
-
- bool setSpriteDirection(const SpriteDirection::Type
- direction A_UNUSED) override final
- { return false; }
-
- int getNumberOfLayers() const A_WARN_UNUSED
- { return 1; }
-
- unsigned int getCurrentFrame() const override final A_WARN_UNUSED
- { return 0; }
-
- unsigned int getFrameCount() const override final A_WARN_UNUSED
- { return 1; }
-
- bool updateNumber(const unsigned num A_UNUSED) override final
- { return false; }
-
- private:
- Image *mImage;
-};
-
-#endif // RESOURCES_SPRITE_IMAGESPRITE_H
diff --git a/src/resources/sprite/sprite.h b/src/resources/sprite/sprite.h
deleted file mode 100644
index 0b75feb73..000000000
--- a/src/resources/sprite/sprite.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SPRITE_SPRITE_H
-#define RESOURCES_SPRITE_SPRITE_H
-
-#include "resources/sprite/spritedef.h"
-
-#include "localconsts.h"
-
-class Graphics;
-class Image;
-
-class Sprite notfinal
-{
- public:
- A_DELETE_COPY(Sprite)
-
- virtual ~Sprite()
- { }
-
- /**
- * Resets the sprite.
- *
- * @returns true if the sprite changed, false otherwise
- */
- virtual bool reset() = 0;
-
- /**
- * Plays an action using the current direction.
- *
- * @returns true if the sprite changed, false otherwise
- */
- virtual bool play(const std::string &action) = 0;
-
- /**
- * Inform the animation of the passed time so that it can output the
- * correct animation frame.
- *
- * @returns true if the sprite changed, false otherwise
- */
- virtual bool update(const int time) = 0;
-
- /**
- * Draw the current animation frame at the coordinates given in screen
- * pixels.
- */
- virtual void draw(Graphics *const graphics,
- const int posX, const int posY)
- const A_NONNULL(2) = 0;
-
- /**
- * Gets the width in pixels of the image of the current frame
- */
- virtual int getWidth() const A_WARN_UNUSED = 0;
-
- /**
- * Gets the height in pixels of the image of the current frame
- */
- virtual int getHeight() const A_WARN_UNUSED = 0;
-
- /**
- * Returns a reference to the current image being drawn.
- */
- virtual const Image* getImage() const A_WARN_UNUSED = 0;
-
- /**
- * Sets the direction.
- *
- * @returns true if the sprite changed, false otherwise
- */
- virtual bool setSpriteDirection(const SpriteDirection::Type
- direction) = 0;
-
- /**
- * Sets the alpha value of the animated sprite
- */
- virtual void setAlpha(float alpha)
- { mAlpha = alpha; }
-
- /**
- * Returns the current alpha opacity of the animated sprite.
- */
- virtual float getAlpha() const A_WARN_UNUSED
- { return mAlpha; }
-
- /**
- * Returns the current frame number for the sprite.
- */
- virtual unsigned int getCurrentFrame() const A_WARN_UNUSED = 0;
-
- /**
- * Returns the frame count for the sprite.
- */
- virtual unsigned int getFrameCount() const A_WARN_UNUSED = 0;
-
- virtual const void *getHash() const A_WARN_UNUSED
- { return nullptr; }
-
- virtual const void *getHash2() const A_WARN_UNUSED
- { return this; }
-
- virtual bool updateNumber(const unsigned num) = 0;
-
- protected:
- Sprite() :
- mAlpha()
- {
- }
-
- float mAlpha; /**< The alpha opacity used to draw */
-};
-
-#endif // RESOURCES_SPRITE_SPRITE_H
diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp
deleted file mode 100644
index aa79ef9f8..000000000
--- a/src/resources/sprite/spritedef.cpp
+++ /dev/null
@@ -1,694 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/sprite/spritedef.h"
-
-#include "configuration.h"
-#include "settings.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "const/resources/map/map.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-
-#include "resources/action.h"
-#include "resources/imageset.h"
-
-#include "resources/animation/animation.h"
-
-#include "resources/dye/dye.h"
-
-#include "resources/loaders/imagesetloader.h"
-#include "resources/loaders/xmlloader.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "debug.h"
-
-SpriteReference *SpriteReference::Empty = nullptr;
-
-const Action *SpriteDef::getAction(const std::string &action,
- const unsigned num) const
-{
- Actions::const_iterator i = mActions.find(num);
- if (i == mActions.end() && num != 100)
- i = mActions.find(100);
-
- if (i == mActions.end() || ((*i).second == nullptr))
- return nullptr;
-
- const ActionMap *const actMap = (*i).second;
- if (actMap == nullptr)
- return nullptr;
- const ActionMap::const_iterator it = actMap->find(action);
-
- if (it == actMap->end())
- {
- logger->log("Warning: no action \"%s\" defined!", action.c_str());
- return nullptr;
- }
-
- return (*it).second;
-}
-
-unsigned SpriteDef::findNumber(const unsigned num) const
-{
- unsigned min = 101;
- FOR_EACH (Actions::const_iterator, it, mActions)
- {
- const unsigned n = (*it).first;
- if (n >= num && n < min)
- min = n;
- }
- if (min == 101)
- return 0;
- return min;
-}
-
-SpriteDef *SpriteDef::load(const std::string &animationFile,
- const int variant, const bool prot)
-{
- BLOCK_START("SpriteDef::load")
- const size_t pos = animationFile.find('|');
- std::string palettes;
- if (pos != std::string::npos)
- palettes = animationFile.substr(pos + 1);
-
- XML::Document *const doc = Loader::getXml(animationFile.substr(0, pos),
- UseVirtFs_true,
- SkipError_false);
- if (doc == nullptr)
- return nullptr;
- XmlNodePtrConst rootNode = doc->rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "sprite"))
- {
- reportAlways("Error, failed to parse sprite %s",
- animationFile.c_str());
- const std::string errorFile = pathJoin(paths.getStringValue("sprites"),
- paths.getStringValue("spriteErrorFile"));
- BLOCK_END("SpriteDef::load")
- doc->decRef();
- if (animationFile != errorFile)
- return load(errorFile, 0, prot);
- return nullptr;
- }
-
- SpriteDef *const def = new SpriteDef;
- def->mSource = animationFile;
- def->mProcessedFiles.insert(animationFile);
- def->loadSprite(rootNode, variant, palettes);
- def->substituteActions();
- if (settings.fixDeadAnimation)
- def->fixDeadAction();
- if (prot)
- {
- def->incRef();
- def->mProtected = true;
- }
- doc->decRef();
- BLOCK_END("SpriteDef::load")
- return def;
-}
-
-void SpriteDef::fixDeadAction()
-{
- FOR_EACH (ActionsIter, it, mActions)
- {
- ActionMap *const d = (*it).second;
- if (d == nullptr)
- continue;
- const ActionMap::iterator i = d->find(SpriteAction::DEAD);
- const ActionMap::iterator i2 = d->find(SpriteAction::STAND);
- // search dead action and check what it not same with stand action
- if (i != d->end() &&
- i->second != nullptr &&
- (i2 == d->end() || i->second != i2->second))
- {
- (i->second)->setLastFrameDelay(0);
- }
- }
-}
-
-void SpriteDef::substituteAction(const std::string &restrict complete,
- const std::string &restrict with)
-{
- FOR_EACH (ActionsConstIter, it, mActions)
- {
- ActionMap *const d = (*it).second;
- if (reportTrue(d == nullptr))
- continue;
- if (d->find(complete) == d->end())
- {
- const ActionMap::iterator i = d->find(with);
- if (i != d->end())
- (*d)[complete] = i->second;
- }
- }
-}
-
-void SpriteDef::substituteActions()
-{
- substituteAction(SpriteAction::STAND, SpriteAction::DEFAULT);
- substituteAction(SpriteAction::MOVE, SpriteAction::STAND);
- substituteAction(SpriteAction::ATTACK, SpriteAction::STAND);
- substituteAction(SpriteAction::CAST, SpriteAction::ATTACK);
- substituteAction(SpriteAction::SIT, SpriteAction::STAND);
- substituteAction(SpriteAction::SITTOP, SpriteAction::SIT);
- substituteAction(SpriteAction::DEAD, SpriteAction::STAND);
- substituteAction(SpriteAction::SPAWN, SpriteAction::STAND);
- substituteAction(SpriteAction::FLY, SpriteAction::MOVE);
- substituteAction(SpriteAction::SWIM, SpriteAction::MOVE);
- substituteAction(SpriteAction::RIDE, SpriteAction::MOVE);
- substituteAction(SpriteAction::STANDSKY, SpriteAction::STAND);
- substituteAction(SpriteAction::STANDWATER, SpriteAction::STAND);
- substituteAction(SpriteAction::STANDRIDE, SpriteAction::STAND);
- substituteAction(SpriteAction::SITSKY, SpriteAction::SIT);
- substituteAction(SpriteAction::SITWATER, SpriteAction::SIT);
- substituteAction(SpriteAction::SITRIDE, SpriteAction::SIT);
- substituteAction(SpriteAction::ATTACKSKY, SpriteAction::ATTACK);
- substituteAction(SpriteAction::ATTACKWATER, SpriteAction::ATTACK);
- substituteAction(SpriteAction::ATTACKRIDE, SpriteAction::ATTACK);
- substituteAction(SpriteAction::CASTSKY, SpriteAction::CAST);
- substituteAction(SpriteAction::CASTWATER, SpriteAction::CAST);
- substituteAction(SpriteAction::CASTRIDE, SpriteAction::CAST);
- substituteAction(SpriteAction::SPAWNSKY, SpriteAction::SPAWN);
- substituteAction(SpriteAction::SPAWNWATER, SpriteAction::SPAWN);
- substituteAction(SpriteAction::SPAWNRIDE, SpriteAction::SPAWN);
- substituteAction(SpriteAction::DEADSKY, SpriteAction::DEAD);
- substituteAction(SpriteAction::DEADWATER, SpriteAction::DEAD);
- substituteAction(SpriteAction::DEADRIDE, SpriteAction::DEAD);
-}
-
-void SpriteDef::loadSprite(XmlNodeConstPtr spriteNode,
- const int variant,
- const std::string &palettes)
-{
- BLOCK_START("SpriteDef::loadSprite")
- if (spriteNode == nullptr)
- {
- BLOCK_END("SpriteDef::loadSprite")
- return;
- }
- // Get the variant
- const int variantCount = XML::getProperty(spriteNode, "variants", 0);
- int variant_offset = 0;
-
- if (variantCount > 0 && variant < variantCount)
- {
- variant_offset = variant * XML::getProperty(spriteNode,
- "variant_offset",
- 0);
- }
-
- for_each_xml_child_node(node, spriteNode)
- {
- if (xmlNameEqual(node, "imageset"))
- loadImageSet(node, palettes);
- else if (xmlNameEqual(node, "action"))
- loadAction(node, variant_offset);
- else if (xmlNameEqual(node, "include"))
- includeSprite(node, variant);
- }
- BLOCK_END("SpriteDef::loadSprite")
-}
-
-void SpriteDef::loadImageSet(XmlNodeConstPtr node,
- const std::string &palettes)
-{
- const std::string name = XML::getProperty(node, "name", "");
-
- // We don't allow redefining image sets. This way, an included sprite
- // definition will use the already loaded image set with the same name.
- if (mImageSets.find(name) != mImageSets.end())
- return;
-
- const int width = XML::getProperty(node, "width", 0);
- const int height = XML::getProperty(node, "height", 0);
- std::string imageSrc = XML::getProperty(node, "src", "");
- Dye::instantiate(imageSrc, palettes);
-
- ImageSet *const imageSet = Loader::getImageSet(imageSrc,
- width, height);
-
- if (imageSet == nullptr)
- {
- reportAlways("%s: Couldn't load imageset: %s",
- mSource.c_str(),
- imageSrc.c_str());
- return;
- }
-
- imageSet->setOffsetX(XML::getProperty(node, "offsetX", 0));
- imageSet->setOffsetY(XML::getProperty(node, "offsetY", 0));
- mImageSets[name] = imageSet;
-}
-
-const ImageSet *SpriteDef::getImageSet(const std::string &imageSetName) const
-{
- const ImageSetCIterator si = mImageSets.find(imageSetName);
- if (si == mImageSets.end())
- {
- reportAlways("%s: Imageset \"%s\" not defined in %s",
- mSource.c_str(),
- imageSetName.c_str(),
- mIdPath.c_str());
- return nullptr;
- }
- return si->second;
-}
-
-void SpriteDef::loadAction(XmlNodeConstPtr node,
- const int variant_offset)
-{
- if (node == nullptr)
- return;
-
- const std::string actionName = XML::getProperty(node, "name", "");
- const std::string imageSetName = XML::getProperty(node, "imageset", "");
- const unsigned hp = XML::getProperty(node, "hp", 100);
- const ImageSet *const imageSet = getImageSet(imageSetName);
-
- if (actionName == SpriteAction::INVALID)
- {
- reportAlways("%s: Unknown action \"%s\" defined in %s",
- mSource.c_str(),
- actionName.c_str(),
- mIdPath.c_str());
- return;
- }
- Action *const action = new Action(actionName);
- action->setNumber(hp);
- addAction(hp, actionName, action);
-
- // dirty hack to fix bad resources in tmw server
- if (actionName == "attack_stab")
- {
- reportAlways("Found legacy attribute attack_stab in animation");
- addAction(hp, "attack", action);
- }
-
- // When first action, set it as default direction.
- // i here always correct, because hp was added above.
- const Actions::const_iterator i = mActions.find(hp);
- if ((*i).second->size() == 1)
- addAction(hp, SpriteAction::DEFAULT, action);
-
- // Load animations
- for_each_xml_child_node(animationNode, node)
- {
- if (xmlNameEqual(animationNode, "animation"))
- loadAnimation(animationNode, action, imageSet, variant_offset);
- }
-}
-
-void SpriteDef::loadAnimation(XmlNodeConstPtr animationNode,
- Action *const action,
- const ImageSet *const imageSet0,
- const int variant_offset) const
-{
- if (action == nullptr ||
- imageSet0 == nullptr ||
- animationNode == nullptr)
- {
- return;
- }
-
- const std::string directionName =
- XML::getProperty(animationNode, "direction", "");
- const SpriteDirection::Type directionType
- = makeSpriteDirection(directionName);
-
- if (directionType == SpriteDirection::INVALID)
- {
- reportAlways("%s: Unknown direction \"%s\" used in %s",
- mSource.c_str(),
- directionName.c_str(),
- mIdPath.c_str());
- return;
- }
-
- Animation *const animation = new Animation(directionName);
- action->setAnimation(directionType, animation);
-
- // Get animation frames
- for_each_xml_child_node(frameNode, animationNode)
- {
- const int delay = XML::getIntProperty(
- frameNode, "delay", 0, 0, 100000);
- const std::string imageSetName = XML::getProperty(frameNode,
- "imageset",
- "");
- const ImageSet *imageSet = imageSet0;
- if (!imageSetName.empty())
- {
- imageSet = getImageSet(imageSetName);
- if (imageSet == nullptr)
- imageSet = imageSet0;
- }
- const int offsetX = XML::getProperty(frameNode, "offsetX", 0)
- + imageSet->getOffsetX() - imageSet->getWidth() / 2
- + mapTileSize / 2;
- const int offsetY = XML::getProperty(frameNode, "offsetY", 0)
- + imageSet->getOffsetY() - imageSet->getHeight() + mapTileSize;
- const int rand = XML::getIntProperty(frameNode, "rand", 100, 0, 100);
-
- if (xmlNameEqual(frameNode, "frame"))
- {
- const int index = XML::getProperty(frameNode, "index", -1);
-
- if (index < 0)
- {
- reportAlways(
- "%s: No valid value for 'index' at direction '%s'",
- mSource.c_str(),
- directionName.c_str());
- continue;
- }
-
- Image *const img = imageSet->get(index + variant_offset);
- if (img == nullptr)
- {
- reportAlways("%s: No image at index %d at direction '%s'",
- mSource.c_str(),
- index + variant_offset,
- directionName.c_str());
- continue;
- }
-
- animation->addFrame(img, delay, offsetX, offsetY, rand);
- }
- else if (xmlNameEqual(frameNode, "sequence"))
- {
- const int start = XML::getProperty(frameNode, "start", -1);
- const int end = XML::getProperty(frameNode, "end", -1);
- const std::string value = XML::getProperty(frameNode, "value", "");
- const int repeat = XML::getIntProperty(
- frameNode, "repeat", 1, 0, 100);
-
- if (repeat < 1)
- {
- reportAlways("%s: No valid value for 'repeat' at direction %s",
- mSource.c_str(),
- directionName.c_str());
- continue;
- }
-
- if (value.empty())
- {
- if (addSequence(start, end, delay, offsetX, offsetY,
- variant_offset, repeat, rand, imageSet, animation))
- {
- continue;
- }
- }
- else
- {
- StringVect vals;
- splitToStringVector(vals, value, ',');
- FOR_EACH (StringVectCIter, it, vals)
- {
- const std::string str = *it;
- const size_t idx = str.find('-');
- if (str == "p")
- {
- animation->addPause(delay, rand);
- }
- else if (idx != std::string::npos)
- {
- const int v1 = atoi(str.substr(0, idx).c_str());
- const int v2 = atoi(str.substr(idx + 1).c_str());
- addSequence(v1, v2, delay, offsetX, offsetY,
- variant_offset, repeat, rand, imageSet, animation);
- }
- else
- {
- Image *const img = imageSet->get(atoi(
- str.c_str()) + variant_offset);
- if (img != nullptr)
- {
- animation->addFrame(img, delay,
- offsetX, offsetY, rand);
- }
- }
- }
- }
- }
- else if (xmlNameEqual(frameNode, "pause"))
- {
- animation->addPause(delay, rand);
- }
- else if (xmlNameEqual(frameNode, "end"))
- {
- animation->addTerminator(rand);
- }
- else if (xmlNameEqual(frameNode, "jump"))
- {
- animation->addJump(XML::getProperty(
- frameNode, "action", ""), rand);
- }
- else if (xmlNameEqual(frameNode, "label"))
- {
- const std::string name = XML::getProperty(frameNode, "name", "");
- if (!name.empty())
- animation->addLabel(name);
- }
- else if (xmlNameEqual(frameNode, "goto"))
- {
- const std::string name = XML::getProperty(frameNode, "label", "");
- if (!name.empty())
- animation->addGoto(name, rand);
- }
- } // for frameNode
-}
-
-void SpriteDef::includeSprite(XmlNodeConstPtr includeNode, const int variant)
-{
- std::string filename = XML::getProperty(includeNode, "file", "");
-
- if (filename.empty())
- return;
- filename = pathJoin(paths.getStringValue("sprites"), filename);
-
- if (mProcessedFiles.find(filename) != mProcessedFiles.end())
- {
- reportAlways("%s: Tried to include %s which already is included.",
- mSource.c_str(),
- filename.c_str());
- return;
- }
- mProcessedFiles.insert(filename);
-
- XML::Document *const doc = Loader::getXml(filename,
- UseVirtFs_true,
- SkipError_false);
- if (doc == nullptr)
- return;
- XmlNodeConstPtr rootNode = doc->rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "sprite"))
- {
- reportAlways("%s: No sprite root node in %s",
- mSource.c_str(),
- filename.c_str());
- doc->decRef();
- return;
- }
-
- loadSprite(rootNode, variant);
- doc->decRef();
-}
-
-SpriteDef::~SpriteDef()
-{
- // Actions are shared, so ensure they are deleted only once.
- std::set<Action*> actions;
- FOR_EACH (Actions::iterator, i, mActions)
- {
- FOR_EACHP (ActionMap::iterator, it, (*i).second)
- actions.insert(it->second);
- delete (*i).second;
- }
-
- FOR_EACH (std::set<Action*>::const_iterator, i, actions)
- delete *i;
-
- mActions.clear();
-
- FOR_EACH (ImageSetIterator, i, mImageSets)
- {
- if (i->second != nullptr)
- {
- i->second->decRef();
- i->second = nullptr;
- }
- }
- mImageSets.clear();
-}
-
-SpriteDirection::Type SpriteDef::makeSpriteDirection(const std::string
- &direction)
-{
- if (direction.empty() || direction == "default")
- return SpriteDirection::DEFAULT;
- else if (direction == "up")
- return SpriteDirection::UP;
- else if (direction == "left")
- return SpriteDirection::LEFT;
- else if (direction == "right")
- return SpriteDirection::RIGHT;
- else if (direction == "down")
- return SpriteDirection::DOWN;
- else if (direction == "upleft")
- return SpriteDirection::UPLEFT;
- else if (direction == "upright")
- return SpriteDirection::UPRIGHT;
- else if (direction == "downleft")
- return SpriteDirection::DOWNLEFT;
- else if (direction == "downright")
- return SpriteDirection::DOWNRIGHT;
- else
- return SpriteDirection::INVALID;
-}
-
-void SpriteDef::addAction(const unsigned hp, const std::string &name,
- Action *const action)
-{
- const Actions::const_iterator i = mActions.find(hp);
- if (i == mActions.end())
- mActions[hp] = new ActionMap;
-
- (*mActions[hp])[name] = action;
-}
-
-bool SpriteDef::addSequence(const int start,
- const int end,
- const int delay,
- const int offsetX,
- const int offsetY,
- const int variant_offset,
- int repeat,
- const int rand,
- const ImageSet *const imageSet,
- Animation *const animation) const
-{
- if ((imageSet == nullptr) || (animation == nullptr))
- return true;
-
- if (start < 0 || end < 0)
- {
- reportAlways("%s: No valid value for 'start' or 'end'",
- mSource.c_str());
- return true;
- }
-
- if (start <= end)
- {
- while (repeat > 0)
- {
- int pos = start;
- while (end >= pos)
- {
- Image *const img = imageSet->get(pos + variant_offset);
-
- if (img == nullptr)
- {
- reportAlways("%s: No image at index %d",
- mSource.c_str(),
- pos + variant_offset);
- pos ++;
- continue;
- }
-
- animation->addFrame(img, delay,
- offsetX, offsetY, rand);
- pos ++;
- }
- repeat --;
- }
- }
- else
- {
- while (repeat > 0)
- {
- int pos = start;
- while (end <= pos)
- {
- Image *const img = imageSet->get(pos + variant_offset);
-
- if (img == nullptr)
- {
- reportAlways("%s: No image at index %d",
- mSource.c_str(),
- pos + variant_offset);
- pos ++;
- continue;
- }
-
- animation->addFrame(img, delay,
- offsetX, offsetY, rand);
- pos --;
- }
- repeat --;
- }
- }
- return false;
-}
-
-int SpriteDef::calcMemoryLocal() const
-{
- int sz = static_cast<int>(sizeof(SpriteDef) +
- sizeof(ImageSets) +
- sizeof(Actions) +
- sizeof(std::set<std::string>)) +
- Resource::calcMemoryLocal();
- FOR_EACH (std::set<std::string>::const_iterator, it, mProcessedFiles)
- {
- sz += static_cast<int>((*it).capacity());
- }
- return sz;
-}
-
-int SpriteDef::calcMemoryChilds(const int level) const
-{
- int sz = 0;
- FOR_EACH (ImageSets::const_iterator, it, mImageSets)
- {
- sz += static_cast<int>((*it).first.capacity());
- const ImageSet *const imageSet = (*it).second;
- sz += imageSet->calcMemory(level + 1);
- }
- FOR_EACH (ActionsCIter, it, mActions)
- {
- sz += sizeof(unsigned);
- const ActionMap *const actionMap = (*it).second;
- FOR_EACHP (ActionMap::const_iterator, it2, actionMap)
- {
- sz += static_cast<int>((*it2).first.capacity());
- const Action *const action = (*it2).second;
- sz += action->calcMemory(level + 1);
- }
- }
- return sz;
-}
diff --git a/src/resources/sprite/spritedef.h b/src/resources/sprite/spritedef.h
deleted file mode 100644
index fcb019d31..000000000
--- a/src/resources/sprite/spritedef.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SPRITE_SPRITEDEF_H
-#define RESOURCES_SPRITE_SPRITEDEF_H
-
-#include "enums/resources/spritedirection.h"
-
-#include "utils/xml.h"
-
-#include <map>
-#include <set>
-
-class Action;
-class Animation;
-class ImageSet;
-
-/**
- * Defines a class to load an animation.
- */
-class SpriteDef final : public Resource
-{
- public:
- A_DELETE_COPY(SpriteDef)
-
- /**
- * Loads a sprite definition file.
- */
- static SpriteDef *load(const std::string &file,
- const int variant,
- const bool prot) A_WARN_UNUSED;
-
- /**
- * Returns the specified action.
- */
- const Action *getAction(const std::string &action,
- const unsigned num) const A_WARN_UNUSED;
-
- unsigned findNumber(const unsigned num) const A_WARN_UNUSED;
-
- /**
- * Converts a string into a SpriteDirection enum.
- */
- static SpriteDirection::Type
- makeSpriteDirection(const std::string &direction) A_WARN_UNUSED;
-
- void addAction(const unsigned hp, const std::string &name,
- Action *const action);
-
- int calcMemoryLocal() const override final;
-
- int calcMemoryChilds(const int level) const override final;
-
- bool addSequence(const int start,
- const int end,
- const int delay,
- const int offsetX,
- const int offsetY,
- const int variant_offset,
- int repeat,
- const int rand,
- const ImageSet *const imageSet,
- Animation *const animation) const;
-
- private:
- /**
- * Constructor.
- */
- SpriteDef() :
- Resource(),
- mImageSets(),
- mActions(),
- mProcessedFiles()
- { }
-
- /**
- * Destructor.
- */
- ~SpriteDef();
-
- /**
- * Loads a sprite element.
- */
- void loadSprite(XmlNodeConstPtr spriteNode,
- const int variant,
- const std::string &palettes = "");
-
- /**
- * Loads an imageset element.
- */
- void loadImageSet(XmlNodeConstPtr node,
- const std::string &palettes);
-
- /**
- * Loads an action element.
- */
- void loadAction(XmlNodeConstPtr node,
- const int variant_offset);
-
- /**
- * Loads an animation element.
- */
- void loadAnimation(XmlNodeConstPtr animationNode,
- Action *const action,
- const ImageSet *const imageSet,
- const int variant_offset) const;
-
- /**
- * Include another sprite into this one.
- */
- void includeSprite(XmlNodeConstPtr includeNode,
- const int variant);
-
- const ImageSet *getImageSet(const std::string &imageSetName) const;
-
- /**
- * Complete missing actions by copying existing ones.
- */
- void substituteActions();
-
- /**
- * Fix bad timeout in last dead action frame
- */
- void fixDeadAction();
-
- /**
- * When there are no animations defined for the action "complete", its
- * animations become a copy of those of the action "with".
- */
- void substituteAction(const std::string &restrict complete,
- const std::string &restrict with);
-
- typedef std::map<std::string, ImageSet*> ImageSets;
- typedef ImageSets::iterator ImageSetIterator;
- typedef ImageSets::const_iterator ImageSetCIterator;
- typedef std::map<std::string, Action*> ActionMap;
- typedef std::map<unsigned, ActionMap*> Actions;
- typedef Actions::const_iterator ActionsConstIter;
- typedef Actions::iterator ActionsIter;
- typedef Actions::const_iterator ActionsCIter;
-
- ImageSets mImageSets;
- Actions mActions;
- std::set<std::string> mProcessedFiles;
-};
-
-#endif // RESOURCES_SPRITE_SPRITEDEF_H
diff --git a/src/resources/sprite/spritedisplay.h b/src/resources/sprite/spritedisplay.h
deleted file mode 100644
index cabae7267..000000000
--- a/src/resources/sprite/spritedisplay.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SPRITE_SPRITEDISPLAY_H
-#define RESOURCES_SPRITE_SPRITEDISPLAY_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-struct SpriteReference;
-
-struct SpriteDisplay final
-{
- SpriteDisplay() :
- image(),
- floor(),
- sprites(),
- particles()
- {
- }
-
- A_DEFAULT_COPY(SpriteDisplay)
-
- std::string image;
- std::string floor;
- STD_VECTOR<SpriteReference*> sprites;
- StringVect particles;
-};
-
-#endif // RESOURCES_SPRITE_SPRITEDISPLAY_H
diff --git a/src/resources/sprite/spritereference.h b/src/resources/sprite/spritereference.h
deleted file mode 100644
index 8bc38a532..000000000
--- a/src/resources/sprite/spritereference.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SPRITE_SPRITEREFERENCE_H
-#define RESOURCES_SPRITE_SPRITEREFERENCE_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-struct SpriteReference final
-{
- static SpriteReference *Empty;
-
- SpriteReference() :
- sprite(),
- variant(0)
- {}
-
- SpriteReference(const std::string &sprite0, const int variant0) :
- sprite(sprite0),
- variant(variant0)
- {
- }
-
- A_DELETE_COPY(SpriteReference)
-
- std::string sprite;
- int variant;
-};
-
-typedef STD_VECTOR<SpriteReference*>::const_iterator SpriteRefs;
-
-#endif // RESOURCES_SPRITE_SPRITEREFERENCE_H
diff --git a/src/resources/surfaceimagehelper.cpp b/src/resources/surfaceimagehelper.cpp
deleted file mode 100644
index 3ba959a42..000000000
--- a/src/resources/surfaceimagehelper.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef USE_SDL2
-
-#include "resources/surfaceimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-bool SurfaceImageHelper::mEnableAlphaCache = false;
-
-Image *SurfaceImageHelper::loadSurface(SDL_Surface *const tmpImage)
-{
- return _SDLload(tmpImage);
-}
-
-Image *SurfaceImageHelper::createTextSurface(SDL_Surface *const tmpImage,
- const int width A_UNUSED,
- const int height A_UNUSED,
- const float alpha)
-{
- if (!tmpImage)
- return nullptr;
-
- Image *img;
- bool hasAlpha = false;
- uint8_t *alphaChannel = nullptr;
- SDL_Surface *image = SDLDuplicateSurface(tmpImage);
-
- img = new Image(image, hasAlpha, alphaChannel);
- img->setAlpha(alpha);
- return img;
-}
-
-SDL_Surface* SurfaceImageHelper::SDLDuplicateSurface(SDL_Surface *const
- tmpImage)
-{
- if (!tmpImage || !tmpImage->format)
- return nullptr;
-
- return MSDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
-}
-
-Image *SurfaceImageHelper::_SDLload(SDL_Surface *tmpImage) const
-{
- if (!tmpImage)
- return nullptr;
-
- SDL_Surface *image = convertTo32Bit(tmpImage);
- return new Image(image, false, nullptr);
-}
-
-int SurfaceImageHelper::combineSurface(SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- SDL_Surface *restrict const dst,
- SDL_Rect *restrict const dstrect)
-{
- SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND);
- SDL_BlitSurface(src, srcrect, dst, dstrect);
- return 1;
-}
-
-#endif // USE_SDL2
diff --git a/src/resources/surfaceimagehelper.h b/src/resources/surfaceimagehelper.h
deleted file mode 100644
index d9cd28351..000000000
--- a/src/resources/surfaceimagehelper.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_SURFACEIMAGEHELPER_H
-#define RESOURCES_SURFACEIMAGEHELPER_H
-
-#ifndef USE_SDL2
-#include "resources/sdlimagehelper.h"
-RESOURCES_SDLIMAGEHELPER_H
-
-#else
-
-#include "localconsts.h"
-
-#include "resources/imagehelper.h"
-
-class Dye;
-class Image;
-
-/**
- * Defines a class for loading and storing images.
- */
-class SurfaceImageHelper final : public ImageHelper
-{
- friend class Image;
-
- public:
- SurfaceImageHelper()
- { }
-
- A_DELETE_COPY(SurfaceImageHelper)
-
- ~SurfaceImageHelper()
- { }
-
- /**
- * Loads an image from an SDL surface.
- */
- Image *loadSurface(SDL_Surface *const tmpImage) override final
- A_WARN_UNUSED;
-
- Image *createTextSurface(SDL_Surface *const tmpImage,
- const int width, const int height,
- const float alpha)
- override final A_WARN_UNUSED;
-
- constexpr2 static void SDLSetEnableAlphaCache(const bool n) noexcept2
- { mEnableAlphaCache = n; }
-
- static bool SDLGetEnableAlphaCache() noexcept2 A_WARN_UNUSED
- { return mEnableAlphaCache; }
-
- /**
- * Tells if the image was loaded using OpenGL or SDL
- * @return true if OpenGL, false if SDL.
- */
- RenderType useOpenGL() const noexcept2 override final A_WARN_UNUSED
- { return RENDER_SOFTWARE; }
-
- static SDL_Surface* SDLDuplicateSurface(SDL_Surface *const tmpImage)
- A_WARN_UNUSED;
-
- static int combineSurface(SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- SDL_Surface *restrict const dst,
- SDL_Rect *restrict const dstrect);
-
- protected:
- /** SDL_Surface to SDL_Surface Image loader */
- Image *_SDLload(SDL_Surface *tmpImage) const A_WARN_UNUSED;
-
- static bool mEnableAlphaCache;
-};
-
-#endif // USE_SDL2
-#endif // RESOURCES_SURFACEIMAGEHELPER_H
diff --git a/src/resources/updatefile.h b/src/resources/updatefile.h
deleted file mode 100644
index cc162cf79..000000000
--- a/src/resources/updatefile.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_UPDATEFILE_H
-#define RESOURCES_UPDATEFILE_H
-
-#include "localconsts.h"
-
-#include <string>
-
-struct UpdateFile final
-{
- public:
- UpdateFile() :
- name(),
- hash(),
- type(),
- desc(),
- group(),
- required(false)
- {
- }
-
- A_DEFAULT_COPY(UpdateFile)
-
- std::string name;
- std::string hash;
- std::string type;
- std::string desc;
- std::string group;
- bool required;
-};
-
-#endif // RESOURCES_UPDATEFILE_H
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
deleted file mode 100644
index 9e81f53a7..000000000
--- a/src/resources/wallpaper.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "resources/wallpaper.h"
-
-#include "configuration.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/list.h"
-
-#include "resources/wallpaperdata.h"
-
-#include "utils/cast.h"
-#include "utils/foreach.h"
-
-#include <algorithm>
-
-#ifdef WIN32
-#include <sys/time.h>
-#endif // WIN32
-
-#ifdef __clang__
-#include <ctime>
-#endif // __clang__
-
-#include "debug.h"
-
-static bool wallpaperCompare(const WallpaperData &a, const WallpaperData &b);
-
-static STD_VECTOR<WallpaperData> wallpaperData;
-static bool haveBackup; // Is the backup (no size given) version available?
-
-static std::string wallpaperPath;
-static std::string wallpaperFile;
-
-// Search for the wallpaper path values sequentially..
-static void initDefaultWallpaperPaths()
-{
- // Init the path
- wallpaperPath = branding.getStringValue("wallpapersPath");
-
- if (wallpaperPath.empty() || !VirtFs::isDirectory(wallpaperPath))
- wallpaperPath = paths.getValue("wallpapers", "");
-
- if (wallpaperPath.empty() || !VirtFs::isDirectory(wallpaperPath))
- wallpaperPath = "graphics/images/";
-
- // Init the default file
- wallpaperFile = branding.getStringValue("wallpaperFile");
-
- if (!wallpaperFile.empty() && !VirtFs::isDirectory(wallpaperFile))
- return;
- wallpaperFile = paths.getValue("wallpaperFile", "");
-
- if (wallpaperFile.empty() || VirtFs::isDirectory(wallpaperFile))
- wallpaperFile = "login_wallpaper.png";
-}
-
-static bool wallpaperCompare(const WallpaperData &a, const WallpaperData &b)
-{
- const int aa = a.width * a.height;
- const int ab = b.width * b.height;
-
- return aa > ab ||
- (aa == ab && a.width > b.width);
-}
-
-void Wallpaper::loadWallpapers()
-{
- wallpaperData.clear();
- initDefaultWallpaperPaths();
- VirtFs::List *const imgs = VirtFs::enumerateFiles(wallpaperPath);
-
- FOR_EACH (StringVectCIter, i, imgs->names)
- {
- // First, get the base filename of the image:
- std::string filename = *i;
- const std::string name = filename;
- // If the backup file is found, we tell it.
- if (filename.find(wallpaperFile) != std::string::npos)
- haveBackup = true;
-
- // If the image format is terminated by: "_<width>x<height>.png"
- // It is taken as a potential wallpaper.
-
- size_t separator = filename.rfind('_');
- filename = filename.substr(0, separator);
-
- // Check that the base filename doesn't have any '%' markers.
- separator = filename.find('%');
- if (separator == std::string::npos)
- {
- // Then, append the width and height search mask.
- filename.append("_%10dx%10d.png");
-
- int width;
- int height;
- if (sscanf(name.c_str(),
- filename.c_str(),
- &width,
- &height) == 2)
- {
- WallpaperData wp;
- wp.filename = wallpaperPath;
- wp.filename.append(*i);
- wp.width = width;
- wp.height = height;
- wallpaperData.push_back(wp);
- }
- }
- }
-
- VirtFs::freeList(imgs);
- std::sort(wallpaperData.begin(), wallpaperData.end(), &wallpaperCompare);
-}
-
-std::string Wallpaper::getWallpaper(const int width, const int height)
-{
- WallpaperData wp;
-
- // Wallpaper filename container
- StringVect wallPaperVector;
-
- FOR_EACH (STD_VECTOR<WallpaperData>::const_iterator, iter, wallpaperData)
- {
- wp = *iter;
- if (wp.width <= width && wp.height <= height)
- wallPaperVector.push_back(wp.filename);
- }
-
- // If we've got more than one occurence of a valid wallpaper...
- if (!wallPaperVector.empty())
- {
- // Return randomly a wallpaper between vector[0] and
- // vector[vector.size() - 1]
- srand(CAST_U32(time(nullptr)));
- return wallPaperVector[CAST_S32(static_cast<double>(
- wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))];
- }
-
- // Return the backup file if everything else failed...
- if (haveBackup)
- return pathJoin(wallpaperPath, wallpaperFile);
-
- // Return an empty string if everything else failed
- return std::string();
-}
diff --git a/src/resources/wallpaper.h b/src/resources/wallpaper.h
deleted file mode 100644
index 5cf84c54b..000000000
--- a/src/resources/wallpaper.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_WALLPAPER_H
-#define RESOURCES_WALLPAPER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-/**
- * Handles organizing and choosing of wallpapers.
- */
-class Wallpaper final
-{
- public:
- A_DELETE_COPY(Wallpaper)
-
- /**
- * Reads the folder that contains wallpapers and organizes the
- * wallpapers found by area, width, and height.
- */
- static void loadWallpapers();
-
- /**
- * Returns the largest wallpaper for the given resolution, or the
- * default wallpaper if none are found.
- *
- * @param width the desired width
- * @param height the desired height
- * @return the file to use, or empty if no wallpapers are useable
- */
- static std::string getWallpaper(const int width,
- const int height) A_WARN_UNUSED;
-};
-
-#endif // RESOURCES_WALLPAPER_H
diff --git a/src/resources/wallpaperdata.h b/src/resources/wallpaperdata.h
deleted file mode 100644
index 417911196..000000000
--- a/src/resources/wallpaperdata.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef RESOURCES_WALLPAPERDATA_H
-#define RESOURCES_WALLPAPERDATA_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct WallpaperData final
-{
- WallpaperData() :
- filename(),
- width(0),
- height(0)
- {
- }
-
- A_DEFAULT_COPY(WallpaperData)
-
- std::string filename;
- int width;
- int height;
-};
-
-#endif // RESOURCES_WALLPAPERDATA_H